Submission #148971

#TimeUsernameProblemLanguageResultExecution timeMemory
148971test team (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms376 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "bulb.h" #include "bulb.h" #include<bits/stdc++.h> using namespace std; int l[300100],r[300100]; vector<int> wen,owe; void dfs(int node) { if(wen[node]==-1) l[node]=1; if(wen[node]==-2) l[node]=2; if(wen[node]>=0) { dfs(wen[node]); l[node]=l[wen[node]]; } if(owe[node]==-1) r[node]=1; if(owe[node]==-2) r[node]=2; if(owe[node]>=0) { dfs(owe[node]); r[node]=l[owe[node]]; } } int FindWinner(int T, std::vector<int> L, std::vector<int> R){ int N = L.size(); for(int i=0;i<N;i++) { wen.push_back(L[i]); owe.push_back(R[i]); } dfs(0); if(l[0]==1) return -1; int node=0; while(r[node]==2) { if(wen[node]<0) return 0; node=wen[node]; } //cout<<node<<"Asdf\n"; if(owe[node]<0) return 1; node=owe[node]; while(r[node]==2) { if(wen[node]<0) return 0; node=wen[node]; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...