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 <set>
#include <vector>
using namespace std;
const int N = 1550;
int n;
int p[N];
int r[N];
int cnt[N][N];
int find(int x) {
return p[x] = (p[x] == x ? x : find(p[x]));
}
void unite(int u, int v) {
u = find(u);
v = find(v);
if (u == v) return;
if (r[u] < r[v])
swap(u, v);
for (int z = 0; z < n; z++) {
cnt[u][z] += cnt[v][z];
cnt[z][u] += cnt[z][v];
cnt[v][z] = cnt[z][v] = 0;
}
p[v] = u;
}
void initialize(int _n) {
n = _n;
for (int i = 0; i < n; i++) {
p[i] = i;
r[i] = 1;
for (int j = 0; j < n; j++) if (i != j) {
cnt[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
u = find(u);
v = find(v);
cnt[u][v]--;
cnt[v][u]--;
if (cnt[u][v]) {
return false;
}
unite(u, v);
return true;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |