이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#include "game.h"
int id[1505],p1[1505],p2[1505],cnt=1;
int f1(int a)
{
if(p1[a]==a)return a;
return p1[a]=f1(p1[a]);
}
void un1(int b,int c)
{
p1[f1(b)]=f1(c);
}
int f2(int a)
{
if(p2[a]==a)return a;
return p2[a]=f2(p2[a]);
}
void un2(int b,int c)
{
p2[f2(b)]=f2(c);
}
void initialize(int n) {
for(int i=1;i<=n;i++)p1[i]=i,p2[i]=i;
}
int hasEdge(int u, int v) {
if(f1(u+1)==f1(v+1))
{
return 1;
}else if(f2(u+1)==f2(v+1))
{
return 0;
}else
{
if(cnt==1)
{
un1(u+1,v+1);
cnt=3-cnt;
return 1;
}else
{
un2(u+1,v+1);
cnt=3-cnt;
return 0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |