#include "bulb.h"
#define RED -1
#define BLUE -2
const int MAXN = 3e5 + 10;
int D[MAXN][2];
int LL[MAXN], RR[MAXN];
void dfs(int here){
if(LL[here] > 0) dfs(LL[here]);
if(RR[here] > 0) dfs(RR[here]);
if(LL[here] == RED) D[here][0] = 0;
else if(LL[here] == BLUE) D[here][0] = 1;
else D[here][0] = D[LL[here]][0];
if(RR[here] < 0) D[here][1] |= (RR[here] == RED);
else D[here][1] |= D[RR[here]][0];
if(LL[here] > 0) D[here][1] |= D[LL[here]][1];
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R){
int N = L.size();
for(int i = 0 ; i < N ; i++) LL[i] = L[i], RR[i] = R[i];
dfs(0);
return D[0][T & 1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |