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;
#define maxn 1505
int conn[maxn][maxn];
int par[maxn];
int findset(int u) {
if (par[u] == u) return u;
return par[u] = findset(par[u]);
}
int N;
void initialize(int n) {
N = n;
for (int i = 0; i < n; i++) {
par[i] = i;
for (int j = 0; j < n; j++) {
conn[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
u = findset(u);
v = findset(v);
if (u == v) return 0;
if (conn[u][v] == 1) {
par[v] = u;
for (int i = 0; i < N; i++) {
if (i != u && i != v) {
conn[u][i] = conn[u][i] + conn[v][i];
conn[i][u] = conn[u][i];
}
}
return 1;
}
conn[u][v]--;
conn[v][u]--;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |