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"
#define M 1500
int u[M+1],m[M+1];
int a[M+1][M+1],n;
void initialize(int _n) {
n=_n;
for(int i=0;i<n;i++){
u[i]=i;
m[i]=1;
}
}
int getroot(int x){
return u[x]==x ? x : u[x]=getroot(u[x]);
}
int hasEdge(int p, int q) {
int i,x=getroot(p),y=getroot(q);
a[x][y]++;
a[y][x]++;
if(a[x][y]==m[x]*m[y]){
for(i=0;i<n;i++){
a[x][i]+=a[y][i];
a[i][x]+=a[i][y];
}
m[x]+=m[y];
u[y]=x;
return 1;
}
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... |