이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
bool exist[300100];
vector<int> wen,owe;
void dfs(int node)
{
r[node]=-owe[node];
if(owe[node]>=0)
{
dfs(owe[node]);
r[node]=l[owe[node]];
}
if(r[node]==2)
exist[node]=true;
l[node]=-wen[node];
if(wen[node]>=0)
{
dfs(wen[node]);
l[node]=l[wen[node]];
if(exist[node]==false&&exist[wen[node]])
exist[node]=true;
}
}
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]==2)
return 0;
int node=0,s=0,p=0;
while(r[node]==1)
{
s++;
p++;
if(owe[node]<0)
return 1;
if(!exist[owe[node]])
return 1;
if(r[owe[node]]==2)
p++;
if(wen[node]<0)
break;
node=wen[node];
}
s++;
int first=owe[node];
if(r[node]==2)
{
while(first>=0)
{
s++;
if(r[first]==2)
return 0;
first=wen[first];
}
if(s==N)
return 1;
return 0;
}
if(p==N)
return 0;
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... |