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 path[1500][1500], sz[1500], par[1500], a[1500], n;
int find(int x) {
if (x == par[x]) return x;
return par[x] = find(par[x]);
}
void stunion(int x, int y) {
if (sz[x] < sz[y]) swap(x,y);
sz[x] += sz[y];
par[y] = x;
for (int j = 0; j < n; j++) {
if (j != x && par[j] == j) {
path[j][x] += path[j][y];
path[x][j] = path[j][x];
}
}
}
void initialize(int N) {
n = N;
for (int i = 0; i < n; i++) {
par[i] = i;
sz[i] = 1;
}
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
path[i][j] = 1;
}
int hasEdge(int u, int v) {
v = find(v);
u = find(u);
if (path[u][v] == 1) {
stunion(v,u);
return 1;
}
else {
path[v][u]--;
path[u][v]--;
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... |