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