이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
const int MN = 3e5+5;
int N, i, ok[MN], res[MN], f, f2;
pii ed[MN];
int acc(int n){
if(n<0) return 0;
if(res[n]) return res[n];
res[n]=ed[n].first<0?ed[n].first:acc(ed[n].first);
return res[n];
}
int solve(int n){
while(n>=0){
if(ed[n].second==-2||acc(ed[n].second)==-2) return 0;
n = ed[n].first;
}
return 1;
}
int FindWinner(int T,vi L,vi R){
N = L.size();
int cur = 0;
for(i=0;i<N;i++) ed[i]={L[i],R[i]};
while(cur>=0){
ok[cur] = 1;
if(!f2){
if(solve(ed[cur].second)) f=1;
}
if(ed[cur].second==-2||acc(ed[cur].second)==-2) f2=1;
cur = ed[cur].first;
}
if(acc(0)==-2) return 0;
else return f;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |