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>
using namespace std;
vector<bool> used;
vector<set<int>> cons;
vector<vector<int>> con;
void initialize(int n) {
cons.resize(n);
con.resize(n);
used.resize(n, 0);
for (int i=0; i<n; i++) {
con[i].resize(n, 0);
con[i][i] = 1;
for (int j=0; j<n; j++) {
if (i != j) {
cons[i].insert(j);
}
}
}
}
void removeEdge(int u, int v, int val) {
con[u][v] = val;
con[v][u] = val;
cons[u].erase(v);
cons[v].erase(u);
}
bool update(int u) {
if (cons[u].size() == 1) {
int v = *cons[u].begin();
removeEdge(u, v, 2);
update(v);
return 1;
}
return 0;
}
int hasEdge(int u, int v) {
if (con[u][v] == 1) {
return 0;
}
if (con[u][v] == 2) {
return 1;
}
if (update(u) || update(v)) {
return 1;
}
else {
removeEdge(u, v, 1);
update(u);
update(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... |