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<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... |