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"
#define N 1501
int p[N], sz[N];
int cnt[N][N];
int find(int x){
return (x == p[x] ? x : p[x] = find(p[x]));
}
void initialize(int n){
for(int i = 0; i < n; i++) p[i] = i, sz[i] = 1;
}
int hasEdge(int u, int v) {
v = find(v);
u = find(u);
cnt[v][u]++;
cnt[u][v]++;
if(cnt[v][u] != sz[v] * sz[u]) return 0;
if(v > u){
int a = v;
v = u;
u = a;
}
p[u] = v;
sz[v] += sz[u];
for(int i = 0; i < N; i++)cnt[v][i] += cnt[u][i], cnt[i][v] = cnt[v][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... |