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 <bits/stdc++.h>
const int MAXN=1510;
int n, x, y;
int par[MAXN];
int deg[MAXN][MAXN];
int getpar(int x){ return (par[x]==x?x:par[x]=getpar(par[x]));}
void initialize(int nn){
n=nn;
for (int i=0; i<n; i++){
par[i]=i;
for (int j=0; j<n; j++) deg[i][j]=(i!=j);
}
}
int hasEdge(int u, int v){
x=getpar(u);
y=getpar(v);
assert(x!=y);
deg[x][y]--;
deg[y][x]--;
if (deg[x][y]) return 0;
for (int i=0; i<n; i++){
deg[i][y]+=deg[i][x];
deg[i][x]=0;
deg[y][i]+=deg[x][i];
deg[x][i]=0;
}
par[x]=y;
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |