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 <cassert>
#include <cstdio>
int conn[1505][1505];
int component[1505];
int N;
void initialize(int n) {
N=n;
for(int i=0;i<n;i++){
component[i]=i;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
conn[i][j]=(i!=j);
}
}
}
void connect(int a,int b){
for(int i=0;i<N;i++){
conn[i][a]+=conn[i][b];
conn[i][b]=0;
conn[a][i]+=conn[b][i];
conn[b][i]=0;
}
for(int i=0;i<N;i++){
if(component[i]==b){
component[i]=a;
}
}
}
int hasEdge(int u, int v) {
int a=component[u],b=component[v];
assert(a!=b);
conn[a][b]--;
conn[b][a]--;
if(conn[a][b]==0){
connect(a,b);
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... |