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"
const int N = 2000;
int p[N], c[N], cnt[N][N], pn;
int find(int a){
return p[a] == a ? a : (p[a] = find(p[a]));
}
void merge(int a, int b){
p[b] = p[a];
c[a] += c[b];
for(int i=0; i<pn; i++){
cnt[a][i] += cnt[b][i];
cnt[i][a] += cnt[i][b];
}
}
void initialize(int n) {
pn = n;
for(int i=0; i<pn; i++){
p[i] = i;
c[i] = 1;
}
}
int hasEdge(int u, int v) {
u = find(u);
v = find(v);
cnt[u][v]++;
cnt[v][u]++;
if(cnt[u][v] == c[u]*c[v]){
merge(u, v);
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... |