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 "game.h"
#include <stdio.h>
const int N=1505;
int p[N],d[N][N],n;
int Find(int x){ return p[x]==x?x:p[x]=Find(p[x]);}
void initialize(int N)
{
int i,j;n=N;
for(i=1;i<=n;i++) p[i]=i;
for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) d[i][j]=1;
}
int min(int a, int b){ return a>b?b:a;}
int max(int a, int b){ return a>b?a:b;}
int hasEdge(int u, int v)
{
int i;
u=Find(u+1);
v=Find(v+1);
if(u==v) return 0;
if(u>v) u^=v,v^=u,u^=v;
if(d[u][v]==1)
{
d[u][v]--;
for(i=1;i<=n;i++) d[min(u,i)][max(u,i)]+=d[min(v,i)][max(i,v)];
p[v]=u;
return 1;
}
else
{
d[u][v]--;
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... |