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;
const int N = 1569;
int n, p[N], sz[N], c[N][N];
int root(int v) {
if (p[v] == v)
return v;
return p[v] = root(p[v]);
}
void initialize(int n1) {
n = n1;
for (int i = 0;i < n;i++) {
p[i] = i, sz[i] = 1;
}
for (int i = 0;i < n;i++) {
for (int j = 0;j < n;j++) {
if (i == j)
continue;
c[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
int a = root(u);
int b = root(v);
--c[a][b], --c[b][a];
if (a == b)
return 1;
if (c[a][b] > 0)
return 0;
if (sz[a] < sz[b])
swap(a, b);
p[b] = a;
sz[a] += sz[b];
for (int i = 0;i < n;i++) {
if (i == a || i == b)
continue;
c[a][i] += c[b][i];
c[i][a] += c[b][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... |