# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124941 | 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, cn0, cn1, os[1001001], chk[1001001], ans[1001001], nod[1001001], fu;
vector<int> L, R;
void dfs(int par, int ix){
if(ix==-1) return;
if(ix==-2){
if(cn1==0) fu=1;
if(cn1==2) ans[os[0]]=1, ans[os[1]]=1;
if(cn1==1) ans[os[0]]=1, nod[par]++;
return;
}
cn0++, chk[ix]=0, dfs(ix, L[ix]);
cn0--, os[cn1++]=ix, chk[ix]=1, dfs(ix, R[ix]);
cn1--, chk[ix]=-1;
}
int FindWinner(int N_, int T, vector<int> L_, vector<int> R_){
N=N_; L=L_; R=R_;
for(int i=1; i<=N; i++) chk[i]=-1;
dfs(0, 1);
if(fu) return 0;
return 0;
}
// Current State: 0 0 0 0 0 0 0
// -2 Bulb Path: 1 0 ? ? 1 ? ?
// x o . . x . .
// Availability: x o o o x o o
// Availability는 전체에서 몇개 빠지거나 Path에서 몇개 빠진 형태.