This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include "bulb.h"
using namespace std;
pair<int, int> G[300003];
int nr;
void dfs(int nod, int turns) {
  if(nod == -1) return;
  if(nod == -2) nr++;
  else {
    if(turns == 2) return;
    else if(turns == 1)
      dfs(G[nod].first, turns);
    else {
      dfs(G[nod].first, turns);
      dfs(G[nod].second, turns + 1);
    }
  }
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R){
	int N = L.size();
	int i;
	for(i = 0; L[i] != -1 && L[i] != -2; i = L[i]);
  if(L[i] == -2)
    return 1;
  else {
    for(int i = 0; i < N; i++) {
      G[i] = {L[i], R[i]};
    }
    dfs(0, 0);
    if(nr > 1) return 0;
    else return 1;
  }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |