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 cnt[1505][1505];
int id[1505];
int sz[1505];
int N;
void initialize(int n) {
N = n;
for(int i=0; i<n; i++) sz[i] = 1, id[i] = i;
return;
}
int hasEdge(int u, int v){
u = id[u], v = id[v];
if(cnt[u][v] == sz[u]*sz[v]-1){
// merge v into u
for(int i=0; i<N; i++) cnt[i][u] += cnt[i][v];
for(int i=0; i<N; i++) cnt[u][i] += cnt[v][i];
for(int i=0; i<N; i++) if(id[i] == v) id[i] = u;
sz[u] += sz[v];
return 1;
}
cnt[u][v]++, cnt[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... |