#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int n, T;
vector<int> L, R;
int res[maxn], down[maxn];
void dfs(int u) {
if(u < 0) return ;
dfs(L[u]);
dfs(R[u]);
if(L[u] >= 0) res[u] = res[L[u]];
else res[u] = (L[u] == -1);
down[u] = (L[u] >= 0 ? down[L[u]] : 0) + 1;
}
int FindWinner(int turns, vector<int> leftChild, vector<int> rightChild){
T = turns; L = leftChild; R = rightChild;
n = (int)leftChild.size();
dfs(0);
if(res[0] == 1 && down[0] < n) return 1;
int x = 0;
while(x >= 0) {
if(R[x] >= 0 && res[R[x]] == 1) return 1;
if(R[x] == -1) return 1;
x = L[x];
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |