Submission #172647

#TimeUsernameProblemLanguageResultExecution timeMemory
172647top34051Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms376 KiB
#include "bulb.h" #include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; int n, T; vector<int> L, R; int res[maxn], down[maxn]; void dfs(int u) { if(u < 0) return ; dfs(L[u]); dfs(R[u]); if(L[u] >= 0) res[u] = res[L[u]]; else res[u] = (L[u] == -1); down[u] = (L[u] >= 0 ? down[L[u]] : 0) + 1; } int FindWinner(int turns, vector<int> leftChild, vector<int> rightChild){ T = turns; L = leftChild; R = rightChild; n = (int)leftChild.size(); dfs(0); if(res[0] == 1 && down[0] < n) return 1; int x = 0; while(x >= 0) { if(R[x] >= 0 && res[R[x]] == 1) return 1; if(R[x] == -1) return 1; x = L[x]; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...