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;
const int mx = 105;
int cnt[mx];
int n;
bool used[mx];
struct DSU {
vector<int> par;
DSU(int N) {
par.assign(N, -1);
}
int Find(int u) {
if(par[u] < 0) return u;
else return par[u] = Find(par[u]);
}
bool uni(int u,int v) {
u = Find(u);
v = Find(v);
if(u != v) {
if(par[u] > par[v]) {
swap(u,v);
}
par[u] += par[v];
par[v] = u;
return true;
} else {
return false;
}
}
};
DSU dsu(20);
void initialize(int N) {
n = N;
}
int hasEdge(int u, int v) {
cnt[u]++, cnt[v]++;
if((cnt[u] == n - 1 && !used[u]) || (cnt[v] == n - 1 && !used[v])) {
if(cnt[u] == n - 1 && !used[u]) {
used[u] = 1;
}
if(cnt[v] == n - 1 && !used[v]) {
used[v] = 1;
}
return 1;
}
if(dsu.uni(u,v)) {
return 0;
} else {
used[u] = used[v] = 1;
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... |