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 = 1505;
int n;
int par[N];
int cnt[N][N];
int find(int u) { return u == par[u] ? u : par[u] = find(par[u]); }
void initialize(int _n) {
n = _n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < i; ++j) {
cnt[i][j] = cnt[j][i] = 1;
}
}
for (int i = 0; i < n; ++i) par[i] = i;
}
int hasEdge(int u, int v) {
u = find(u), v = find(v);
if (u == v || cnt[u][v] > 1) {
cnt[u][v]--, cnt[v][u]--;
return 0;
}
cnt[u][v] = cnt[v][u] = 0;
for (int i = 0; i < n; ++i) {
cnt[v][i] += cnt[u][i], cnt[u][i] = 0;
cnt[i][v] += cnt[i][u], cnt[i][u] = 0;
}
par[u] = v; 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... |