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 <bits/stdc++.h>
#include <game.h>
using namespace std;
int n;
vector<int> p, s;
vector<vector<int>> c;
void initialize(int N) {
n = N;
p.resize(n), s.resize(n, 1);
iota(p.begin(), p.end(), 0);
c.assign(n, vector<int>(n));
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
c[i][j] = i != j;
}
int get(int a) {
if (p[a] == a)
return a;
return p[a] = get(p[a]);
}
void unite(int a, int b) {
if (a == b)
return;
if (s[b] > s[a])
swap(a, b);
for (int i = 0; i < n; ++i)
c[i][a] = (c[a][i] += c[b][i]);
c[a][b] = c[b][a] = 0;
s[a] += s[b];
p[b] = a;
}
int hasEdge(int a, int b) {
a = get(a), b = get(b);
if (c[a][b] > 1) {
--c[a][b], --c[b][a];
return 0;
}
unite(a, b);
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... |