Task: | Distance Code |
Sender: | Knut Salomonsson |
Submission time: | 2019-03-06 15:24:30 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#3 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#4 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#5 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#6 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#7 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#8 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#9 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#10 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#11 | WRONG ANSWER | 0.02 s | 1, 2, 3 | details |
#12 | WRONG ANSWER | 0.02 s | 2, 3 | details |
#13 | WRONG ANSWER | 0.01 s | 2, 3 | details |
#14 | WRONG ANSWER | 0.02 s | 2, 3 | details |
#15 | WRONG ANSWER | 0.01 s | 2, 3 | details |
#16 | WRONG ANSWER | 0.04 s | 3 | details |
#17 | WRONG ANSWER | 0.04 s | 3 | details |
#18 | WRONG ANSWER | 0.04 s | 3 | details |
#19 | WRONG ANSWER | 0.05 s | 3 | details |
#20 | WRONG ANSWER | 0.02 s | 1, 2, 3 | 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: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 2 2 1 |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 2
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 3 3 1 2 1 |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 4 3 2 2 1 4 1 |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 4 2 3 3 4 1 3 |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 5
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 5 3 5 4 1 1 3 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 6
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 5 3 2 3 4 5 1 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 7
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 5 4 3 1 4 4 2 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 8
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 10 9 3 8 9 2 9 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 9
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 10 9 2 5 8 7 1 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 10
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 10 10 4 9 1 4 7 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 11
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 10 2 6 4 3 3 5 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 12
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1 500 10 6 6 255 6 428 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 13
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1 500 152 466 451 313 158 479 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 14
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1 500 109 440 330 190 443 161 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 15
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1 500 144 373 257 233 341 318 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 16
Group: 3
Verdict: WRONG ANSWER
input |
---|
1 100000 54983 75172 93807 75172 44082 75172 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 17
Group: 3
Verdict: WRONG ANSWER
input |
---|
1 100000 88863 19059 86423 76688 98536 95984 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 18
Group: 3
Verdict: WRONG ANSWER
input |
---|
1 100000 59979 6389 19097 24999 27846 82330 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 19
Group: 3
Verdict: WRONG ANSWER
input |
---|
1 100000 58761 66001 25102 51081 98625 67861 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |
Test 20
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1 6 2 1 3 2 4 2 ... |
correct output |
---|
(empty) |
user output |
---|
IMPOSSIBLE |