Submission #150568

#TimeUsernameProblemLanguageResultExecution timeMemory
150568먀 (#200)Bulb Game (FXCUP4_bulb)C++17
36 / 100
84 ms8672 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...