#include "bulb.h"
const int RED = -1;
const int BLUE = -2;
using vi = std::vector<int>;
int GetBulb(const vi& L, const vi& R, const vi& S){
int cur = 0;
while(1){
if(S[cur]==0){
if(L[cur]<0) return L[cur];
cur = L[cur];
}
else if(S[cur]==1){
if(R[cur]<0) return R[cur];
cur = R[cur];
}
}
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R){
const int N = L.size();
vi S(N);
for(int i=0;i<N;i++){
S[i] = 1-S[i];
bool all_red = true;
for(int j=0;j<N;j++){
S[j] = 1-S[j];
int res = GetBulb(L, R, S);
if(res==BLUE) all_red = false;
S[j] = 1-S[j];
}
if(all_red) return 1;
S[i] = 1-S[i];
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
14 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
10 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
14 ms |
376 KB |
Output is correct |
10 |
Correct |
10 ms |
368 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
6 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
12 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
14 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
10 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
14 ms |
376 KB |
Output is correct |
12 |
Correct |
10 ms |
368 KB |
Output is correct |
13 |
Correct |
4 ms |
256 KB |
Output is correct |
14 |
Correct |
6 ms |
364 KB |
Output is correct |
15 |
Correct |
8 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
356 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
9 ms |
376 KB |
Output is correct |
21 |
Correct |
14 ms |
376 KB |
Output is correct |
22 |
Correct |
6 ms |
372 KB |
Output is correct |
23 |
Correct |
9 ms |
352 KB |
Output is correct |
24 |
Correct |
11 ms |
256 KB |
Output is correct |
25 |
Correct |
5 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
12 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
14 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
10 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
14 ms |
376 KB |
Output is correct |
12 |
Correct |
10 ms |
368 KB |
Output is correct |
13 |
Correct |
4 ms |
256 KB |
Output is correct |
14 |
Correct |
6 ms |
364 KB |
Output is correct |
15 |
Correct |
8 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
356 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
9 ms |
376 KB |
Output is correct |
21 |
Correct |
14 ms |
376 KB |
Output is correct |
22 |
Correct |
6 ms |
372 KB |
Output is correct |
23 |
Correct |
9 ms |
352 KB |
Output is correct |
24 |
Correct |
11 ms |
256 KB |
Output is correct |
25 |
Correct |
5 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
380 KB |
Output is correct |
27 |
Execution timed out |
1018 ms |
8192 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |