# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147824 | imsifile | Bulb Game (FXCUP4_bulb) | C++17 | 0 ms | 0 KiB |
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"
using namespace std;
int N, rule[303030];
vector<int> L, R;
int dfs(int ix){
if(ix<0) return ix;
if(rule[ix]==0) return dfs(L[ix]);
return dfs(R[ix]);
}
int FindWinner(int N_, int T, std::vector<int> L_, std::vector<int> R_){
N=N_, L=L_, R=R_;
for(int i=0; i<N; i++){
rule[i]^=1;
int fl=1;
for(int j=0; j<N; j++){
rule[j]^=1;
int x=dfs(0);
rule[j]^=1;
if(x==-2){ fl=0; break; }
}
rule[i]^=1;
if(fl) return 1;
}
return 0;
}