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 <bits/stdc++.h>
using namespace std;
struct DSU {
int n, cnt[1505][1505];
vector<int> par, size;
DSU() {
par.resize(1505);
size.resize(1505, 1);
for(int i=0; i<1505; i++) {
par[i] = i;
for(int j=0; j<1505; j++) cnt[i][j] = 0;
}
}
int find(int x) {
if(x == par[x]) return x;
return par[x] = find(par[x]);
}
bool uni(int a, int b) {
a = find(a);
b = find(b);
if(a == b) return 0;
if(cnt[a][b] + 1 < size[a] * size[b]) {
cnt[a][b]++;
cnt[b][a]++;
return 0;
}
if(size[a] < size[b]) swap(a, b);
size[a] += size[b];
par[b] = a;
return 1;
}
} dsu;
void initialize(int n) {
}
int hasEdge(int u, int v) {
return dsu.uni(u, v);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |