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"
int N;
int C[1500][1500];
int T[1500];
int par(int x){
if(T[x]<0)return x;
return T[x]=par(T[x]);
}
void uni(int x,int y){
x=par(x);
y=par(y);
if(x==y)return;
T[x]+=T[y];
T[y]=x;
for(int i=0;i<N;i++){
C[i][x]+=C[i][y];
}
for(int i=0;i<N;i++){
C[x][i]+=C[y][i];
}
}
void initialize(int n) {
N=n;
for(int i=0;i<N;i++){
T[i]=-1;
}
}
int hasEdge(int u, int v) {
u=par(u);
v=par(v);
if(C[u][v]==T[u]*T[v]-1){
uni(u,v);
return 1;
}
else{
C[u][v]++;
C[v][u]++;
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... |