Submission #148671

#TimeUsernameProblemLanguageResultExecution timeMemory
148671Cafe Maru (#200)Bulb Game (FXCUP4_bulb)C++17
36 / 100
1018 ms8192 KiB
#include "bulb.h" const int RED = -1; const int BLUE = -2; using vi = std::vector<int>; int GetBulb(const vi& L, const vi& R, const vi& S){ int cur = 0; while(1){ if(S[cur]==0){ if(L[cur]<0) return L[cur]; cur = L[cur]; } else if(S[cur]==1){ if(R[cur]<0) return R[cur]; cur = R[cur]; } } } int FindWinner(int T, std::vector<int> L, std::vector<int> R){ const int N = L.size(); vi S(N); for(int i=0;i<N;i++){ S[i] = 1-S[i]; bool all_red = true; for(int j=0;j<N;j++){ S[j] = 1-S[j]; int res = GetBulb(L, R, S); if(res==BLUE) all_red = false; S[j] = 1-S[j]; } if(all_red) return 1; S[i] = 1-S[i]; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...