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 N = 300005;
int n, ans[N][2];
vector<int> l, r;
bool ini[N];
bool getini (int I) {
if(I < 0) return I == -1;
return ini[I];
}
bool solve (int I, int V) {
if(V < 0) return false;
if(I < 0) return true;
if(ans[I][V]) return ans[I][V] - 1;
if(getini(r[I])) ans[I][V] |= solve(l[I], V);
if(getini(l[I])) ans[I][V] |= solve(r[I], V-1);
ans[I][V]++;
return ans[I][V] - 1;
}
void calc (int I) {
if(I < 0) return;
calc(l[I]);
calc(r[I]);
ini[I] = getini(l[I]);
}
int FindWinner(int T, vector<int> L, vector<int> R){
n = L.size();
l = L; r = R;
calc(0);
return solve(0, 1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |