Task: | Thieves and Prisons |
Sender: | Knut Salomonsson |
Submission time: | 2019-03-06 15:24:10 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
#4 | WRONG ANSWER | 0 |
#5 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 2, 4, 5 | details |
#2 | WRONG ANSWER | 0.02 s | 2, 4, 5 | details |
#3 | WRONG ANSWER | 0.03 s | 2, 4, 5 | details |
#4 | WRONG ANSWER | 0.02 s | 2, 4, 5 | details |
#5 | WRONG ANSWER | 0.03 s | 2, 4, 5 | details |
#6 | ACCEPTED | 0.01 s | 4, 5 | details |
#7 | WRONG ANSWER | 0.03 s | 4, 5 | details |
#8 | ACCEPTED | 0.01 s | 4, 5 | details |
#9 | ACCEPTED | 0.02 s | 1, 3, 4, 5 | details |
#10 | ACCEPTED | 0.02 s | 1, 3, 4, 5 | details |
#11 | ACCEPTED | 0.01 s | 1, 3, 4, 5 | details |
#12 | WRONG ANSWER | 0.02 s | 1, 3, 4, 5 | details |
#13 | ACCEPTED | 0.01 s | 1, 3, 4, 5 | details |
#14 | ACCEPTED | 0.01 s | 1, 3, 4, 5 | details |
#15 | ACCEPTED | 0.02 s | 1, 3, 4, 5 | details |
#16 | WRONG ANSWER | 0.01 s | 1, 3, 4, 5 | details |
#17 | WRONG ANSWER | 0.02 s | 1, 2, 3, 4, 5 | details |
#18 | ACCEPTED | 0.03 s | 1, 3, 4, 5 | details |
#19 | RUNTIME ERROR | 0.34 s | 2, 5 | details |
#20 | RUNTIME ERROR | 0.35 s | 2, 5 | details |
#21 | RUNTIME ERROR | 0.35 s | 2, 5 | details |
#22 | RUNTIME ERROR | 0.34 s | 5 | details |
#23 | RUNTIME ERROR | 0.36 s | 5 | details |
#24 | ACCEPTED | 0.02 s | 3, 4, 5 | details |
#25 | ACCEPTED | 0.02 s | 3, 4, 5 | details |
#26 | ACCEPTED | 0.02 s | 3, 4, 5 | details |
#27 | ACCEPTED | 0.02 s | 3, 4, 5 | details |
#28 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
#29 | WRONG ANSWER | 0.02 s | 4, 5 | details |
#30 | WRONG ANSWER | 0.03 s | 4, 5 | details |
#31 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
#32 | TIME LIMIT EXCEEDED | -- | 2, 4, 5 | details |
#33 | WRONG ANSWER | 0.02 s | 2, 4, 5 | details |
#34 | WRONG ANSWER | 0.02 s | 2, 4, 5 | details |
#35 | TIME LIMIT EXCEEDED | -- | 2, 4, 5 | details |
#36 | RUNTIME ERROR | 0.36 s | 3, 5 | details |
#37 | RUNTIME ERROR | 0.35 s | 3, 5 | details |
#38 | RUNTIME ERROR | 0.37 s | 3, 5 | details |
#39 | RUNTIME ERROR | 0.34 s | 3, 5 | details |
#40 | TIME LIMIT EXCEEDED | -- | 5 | details |
#41 | WRONG ANSWER | 0.07 s | 5 | details |
#42 | WRONG ANSWER | 0.08 s | 5 | details |
#43 | TIME LIMIT EXCEEDED | -- | 5 | details |
#44 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
#45 | WRONG ANSWER | 0.07 s | 2, 5 | details |
#46 | WRONG ANSWER | 0.09 s | 2, 5 | details |
#47 | TIME LIMIT EXCEEDED | -- | 2, 5 | details |
Code
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef pair<int, int> pi; #define rep(i, a, b) for(int i = a;i<b;i++) #define iter(it, obj) for(auto it = obj.begin();it != obj.end();it++) vector<char> evs; vi thieves; int n, m, k; vi dp(int i, vector<bool> free, vector<vi > pris, int out){ char c = evs[i]; int t = thieves[i]; if(c == 'C'){ if(!free[t]) return {-1}; if(i == m-1){ return {1}; } free[t] = false; out--; pris[0].push_back(t); vi arr1 = dp(i+1,free, pris, out); if(arr1[0] != -1){ arr1.insert(arr1.begin(),1); return arr1; } pris[0].pop_back(); pris[1].push_back(t); vi arr2 = dp(i+1, free, pris, out); if(arr2[0] != -1){ arr2.insert(arr2.begin(),2); return arr2; } return {-1}; } if(c == 'O'){ if(pris[0].size() == 0 && pris[1].size() == 0) return {-1}; if(!free[t]) return {-1}; if(i == m-1){ if(pris[0].size()>0) return {1}; else return {2}; } if(pris[0].size() > 0){ int send = out; iter(it, pris[0]){ free[*it] = true; send++; } vector<vi > cop = pris; cop[0].clear(); vi arr1 = dp(i+1, free, cop, send); if(arr1[0] != -1){ arr1.insert(arr1.begin(), 1); return arr1; } } if(pris[1].size()>0){ int send = out; iter(it, pris[1]){ free[*it] = true; send++; } vector<vi > cop = pris; cop[1].clear(); vi arr2 = dp(i+1, free, cop, send); if(arr2[0] != -1){ arr2.insert(arr2.begin(), 2); return arr2; } } } return {-1}; } int main(){ cin >> n >>k >> m; thieves.resize(m); evs.resize(m); rep(i,0, m){ cin >> evs[i] >> thieves[i]; thieves[i]--; } vector<bool> tmp1 = vector<bool>(n, true); vector<vi > tmp2 = vector<vi >(2, vi()); vi arr = dp(0, tmp1, tmp2, n); if(arr[0] == -1){ cout << "Impossible"<<endl; return 0; } iter(it, arr){ cout << *it<<endl; } }
Test details
Test 1
Group: 2, 4, 5
Verdict: ACCEPTED
input |
---|
1 1 1 C 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Group: 2, 4, 5
Verdict: WRONG ANSWER
input |
---|
1 1 1 O 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
Impossible |
Test 3
Group: 2, 4, 5
Verdict: WRONG ANSWER
input |
---|
1 1 2 C 1 C 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
Impossible |
Test 4
Group: 2, 4, 5
Verdict: WRONG ANSWER
input |
---|
1 1 2 C 1 O 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
Impossible |
Test 5
Group: 2, 4, 5
Verdict: WRONG ANSWER
input |
---|
1 1 2 O 1 C 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
Impossible |
Test 6
Group: 4, 5
Verdict: ACCEPTED
input |
---|
2 1 2 C 1 C 2 |
correct output |
---|
1 1 |
user output |
---|
1 1 |
Test 7
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
2 1 2 C 1 O 1 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
Impossible |
Test 8
Group: 4, 5
Verdict: ACCEPTED
input |
---|
2 1 2 C 1 O 2 |
correct output |
---|
1 1 |
user output |
---|
1 1 |
Test 9
Group: 1, 3, 4, 5
Verdict: ACCEPTED
input |
---|
3 2 5 C 1 C 2 O 3 C 1 ... |
correct output |
---|
1 1 1 1 1 |
user output |
---|
1 1 1 1 1 |
Test 10
Group: 1, 3, 4, 5
Verdict: ACCEPTED
input |
---|
3 2 5 C 1 C 2 O 3 O 3 ... |
correct output |
---|
2 1 2 1 1 |
user output |
---|
1 2 1 2 1 |
Test 11
Group: 1, 3, 4, 5
Verdict: ACCEPTED
input |
---|
3 2 5 C 1 C 2 O 3 O 1 ... |
correct output |
---|
2 1 2 1 1 |
user output |
---|
1 2 1 2 1 |
Test 12
Group: 1, 3, 4, 5
Verdict: WRONG ANSWER
input |
---|
3 2 5 C 1 C 2 O 1 O 3 ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
Impossible |
Test 13
Group: 1, 3, 4, 5
Verdict: ACCEPTED
input |
---|
3 2 4 C 1 O 2 C 1 O 3 |
correct output |
---|
1 1 1 1 |
user output |
---|
1 1 1 1 |
Test 14
Group: 1, 3, 4, 5
Verdict: ACCEPTED
input |
---|
3 2 4 C 1 O 2 C 2 O 1 |
correct output |
---|
1 1 1 1 |
user output |
---|
1 1 1 1 |
Test 15
Group: 1, 3, 4, 5
Verdict: ACCEPTED
input |
---|
3 2 3 C 1 C 2 C 3 |
correct output |
---|
1 1 1 |
user output |
---|
1 1 1 |
Test 16
Group: 1, 3, 4, 5
Verdict: WRONG ANSWER
input |
---|
3 2 3 O 1 C 2 C 3 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
Impossible |
Test 17
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
input |
---|
2 2 7 C 1 O 2 O 2 O 2 ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
Impossible |
Test 18
Group: 1, 3, 4, 5
Verdict: ACCEPTED
input |
---|
4 2 5 C 2 O 3 C 1 O 4 ... |
correct output |
---|
1 1 1 1 1 |
user output |
---|
1 1 1 1 1 |
Test 19
Group: 2, 5
Verdict: RUNTIME ERROR
input |
---|
100000 100000 100000 C 1 C 2 C 3 C 4 ... |
correct output |
---|
50000 49999 49998 49997 49996 ... |
user output |
---|
(empty) |
Test 20
Group: 2, 5
Verdict: RUNTIME ERROR
input |
---|
100000 100000 100000 C 1 C 2 C 3 C 4 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 21
Group: 2, 5
Verdict: RUNTIME ERROR
input |
---|
100000 100000 100000 C 1 C 2 C 3 C 4 ... |
correct output |
---|
20000 20000 20000 20000 20000 ... |
user output |
---|
(empty) |
Test 22
Group: 5
Verdict: RUNTIME ERROR
input |
---|
100000 100 100000 C 1 C 2 C 3 C 4 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 23
Group: 5
Verdict: RUNTIME ERROR
input |
---|
100000 99 100000 C 1 C 2 C 3 C 4 ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
(empty) |
Test 24
Group: 3, 4, 5
Verdict: ACCEPTED
input |
---|
500 2 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 25
Group: 3, 4, 5
Verdict: ACCEPTED
input |
---|
500 2 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 26
Group: 3, 4, 5
Verdict: ACCEPTED
input |
---|
500 2 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 27
Group: 3, 4, 5
Verdict: ACCEPTED
input |
---|
500 2 500 C 384 O 62 C 387 C 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 ... Truncated |
Test 28
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
500 250 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 29
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
500 250 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 2 1 3 ... |
user output |
---|
Impossible |
Test 30
Group: 4, 5
Verdict: WRONG ANSWER
input |
---|
500 250 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 1 3 2 3 3 2 2 2 5 4 2 ... |
user output |
---|
Impossible |
Test 31
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
500 250 500 C 384 O 62 C 387 C 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 32
Group: 2, 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
500 500 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 33
Group: 2, 4, 5
Verdict: WRONG ANSWER
input |
---|
500 500 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 2 1 3 ... |
user output |
---|
Impossible |
Test 34
Group: 2, 4, 5
Verdict: WRONG ANSWER
input |
---|
500 500 500 C 384 O 62 C 387 O 473 ... |
correct output |
---|
1 1 1 1 2 1 3 3 3 2 2 2 2 4 5 ... |
user output |
---|
Impossible |
Test 35
Group: 2, 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
500 500 500 C 384 O 62 C 387 C 473 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 36
Group: 3, 5
Verdict: RUNTIME ERROR
input |
---|
100000 2 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 37
Group: 3, 5
Verdict: RUNTIME ERROR
input |
---|
100000 2 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 ... |
user output |
---|
(empty) |
Test 38
Group: 3, 5
Verdict: RUNTIME ERROR
input |
---|
100000 2 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 ... |
user output |
---|
(empty) |
Test 39
Group: 3, 5
Verdict: RUNTIME ERROR
input |
---|
100000 2 100000 C 89384 O 54062 C 85387 C 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 40
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 50000 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 41
Group: 5
Verdict: WRONG ANSWER
input |
---|
100000 50000 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 3 2 1 ... |
user output |
---|
Impossible |
Test 42
Group: 5
Verdict: WRONG ANSWER
input |
---|
100000 50000 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 1 3 2 3 3 3 3 3 3 4 5 ... |
user output |
---|
Impossible |
Test 43
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 50000 100000 C 89384 O 54062 C 85387 C 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 44
Group: 2, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |
Test 45
Group: 2, 5
Verdict: WRONG ANSWER
input |
---|
100000 100000 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 3 2 1 ... |
user output |
---|
Impossible |
Test 46
Group: 2, 5
Verdict: WRONG ANSWER
input |
---|
100000 100000 100000 C 89384 O 54062 C 85387 O 53318 ... |
correct output |
---|
1 1 1 1 2 1 3 3 3 3 3 3 4 5 3 ... |
user output |
---|
Impossible |
Test 47
Group: 2, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 100000 C 89384 O 54062 C 85387 C 53318 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
(empty) |