#include <bits/stdc++.h>
#include "bulb.h"
using namespace std;
typedef tuple <int, int, int, int, int> tii;
vector <int> L, R;
int n;
tii dfs(int p)
{
int d0, d1, d2, d3, s;
int l0, l1, l2, l3, ls;
int r0, r1, r2, r3, rs;
if(p < 0) d0 = -p, d1 = d2 = d3 = s = 0;
else{
tie(l0, l1, l2, l3, ls) = dfs(L[p]);
tie(r0, r1, r2, r3, rs) = dfs(R[p]);
s = ls + rs + 1;
d0 = l0;
d1 = l1 | r0;
if(rs > 0) d1 |= l0;
d2 = l2 | r0;
if(rs > 0) d2 |= l0;
d3 = d0;
if(d0 == 1){
if(!(l3 & 2) && r0 != 2) {}
else if(!(r2 & 2)) {}
else if(!(l2 & 2) && (r1 & 1)) {}
else d3 |= 2;
}
else{
if(!(l3 & 1) && r0 != 1) {}
else if(!(r2 & 1)) {}
else if(!(l2 & 1) && (r1 & 2)) {}
else d3 |= 1;
}
}
return tii(d0, d1, d2, d3, s);
}
int FindWinner(int T, vector <int> _L, vector<int> _R)
{
n = L.size(); swap(L, _L); swap(R, _R);
int d0, d1, d2, d3, s;
tie(d0, d1, d2, d3, s) = dfs(0);
if(d3 | 2) return 0;
else return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |