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;
int p[1505];
set<pair<int, int>> st[1505];
int find(int x) {
if (p[x] == x) {
return x;
}
p[x] = find(p[x]);
return p[x];
}
void merge(int a, int b) {
a = find(a);
b = find(b);
if (a == b) {
return;
}
p[b] = a;
}
void initialize(int n) {
for (int i = 0; i < n; i++) {
p[i] = i;
}
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
st[i].insert({i, j});
st[j].insert({i, j});
}
}
}
int hasEdge(int u, int v) {
if (st[u].size() < 3 && st[v].size() < 3) {
st[u].erase({u, v});
st[v].erase({u, v});
merge(u, v);
return 1;
}
if (st[u].size() < 2 || st[v].size() < 2) {
st[u].erase({u, v});
st[v].erase({u, v});
merge(u, v);
return 1;
}
st[u].erase({u, v});
st[v].erase({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... |