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;
// trans rights
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
int par[1569];
vector<int> grp[1569];
int done[1569][1569];
int fnd(int x) {
return x == par[x] ? x : (par[x] = fnd(par[x]));
}
void initialize(int n) {
for (int i = 0; i < n; i++) {
par[i] = i;
grp[i].push_back(i);
}
}
int hasEdge(int u, int v) {
done[u][v] = done[v][u] = true;
u = fnd(u); v = fnd(v);
if (u == v) return 0;
for (auto x : grp[u]) {
for (auto y : grp[v]) {
if (!done[x][y]) return 0;
}
}
if (grp[u].size() < grp[v].size()) swap(u, v);
for (auto i : grp[v]) grp[u].push_back(i);
par[v] = u;
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... |