Submission #150145

#TimeUsernameProblemLanguageResultExecution timeMemory
150145Weeeee (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms376 KiB
#include "bulb.h" #include <bits/stdc++.h> using namespace std; const int Nmax = 3e5 + 5; bool bad = 0; int v1[Nmax], v2[Nmax]; int subarb[Nmax]; int dfs(int node, vector<int> &L, vector<int> &R, int e1, int e2, int e3) { if(node == -1) return 0; if(node == -2) { if(e1 == -1) bad = 1; else if(e2 == -1) return 1; else if(e3 == -1) { v2[e1]++; v2[e2]++; } return 0; } int ans = dfs(L[node], L, R, e1, e2, e3); if(e1 == -1) e1 = node; else if(e2 == -1) e2 = node; else if(e3 == -1) e3 = node; ans += dfs(R[node], L, R, e1, e2, e3); subarb[node] = ans; } int FindWinner(int T, std::vector<int> L, std::vector<int> R) { int n = L.size(); int e1 = -1, e2 = -1, e3 = -1; int total = dfs(0, L, R, e1, e2, e3); int i; if(bad) return 0; for(i=0; i<n; ++i) { /// E chestii cu un turn, dar nu in subarb lui node if(v2[i]) continue; if(total - subarb[i]) continue; return 1; } return 0; }

Compilation message (stderr)

bulb.cpp: In function 'int dfs(int, std::vector<int>&, std::vector<int>&, int, int, int)':
bulb.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...