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 <cstdio>
int con[1501][1501];
int siz[1501];
int rep[1501];
int N;
int findrep(int n) {
while(n!=rep[n]) n = rep[n];
return n;
}
void initialize(int n) {
N = n;
for(int i=0; i<=n; i++) {
siz[i] = 1;
rep[i] = i;
}
}
int hasEdge(int u, int v) {
int x = findrep(u);
int y = findrep(v);
if(con[x][y] != siz[x]*siz[y]-1) {
con[x][y]++;
con[y][x]++;
return 0;
}
//merge u and v
rep[y] = x;
siz[x]+=siz[y];
for (int i = 0; i < N; ++i) con[x][i]+=con[y][i];
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... |