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 v, u, n, pth[1500][1500], sz[1500], par[1500], a[1500], dead[1500];
int find(int x) {
if (v == par[v]) return v;
return par[v] = find(par[v]);
}
void merge(int x, int y) {
x = find(x);
y = find(y);
// if (x != y) {
if (sz[x] < sz[y]) swap(x,y);
for (int j = 0; j < n; j++) {
pth[y][j] += sz[x];
pth[j][y] += sz[x];
}
par[y] = x;
sz[x] += sz[y];
// }
}
void initialize(int 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++)
//if (i != j) pth[i][j] = sz[]*sz[];
pth[i][j] = 1;
}
int hasEdge(int u, int v) {
if (pth[v][u] == 1) {
merge(v,u);
return 1;
}
else {
return 0;
pth[v][u]--;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |