This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |