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>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
using namespace std;
vector<bool> used;
vector<vector<int>> con;
void initialize(int n) {
con.resize(n);
used.resize(n, 0);
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
if (j == i) {
continue;
}
con[i].push_back(j);
}
}
}
bool dfs(int curr, int par, int en) {
if (curr == en) {
return 1;
}
used[curr] = 1;
for (auto to : con[curr]) {
if (to != par && !used[to]) {
if (dfs(to, curr, en)) {
return 1;
}
}
}
return 0;
}
void removeEdge(int u, int v) {
for (int i=0; i<(int)con[u].size(); i++) {
if (con[u][i] == v) {
swap(con[u][i], con[u].back());
con[u].pop_back();
}
}
}
int hasEdge(int u, int v) {
fill(used.begin(), used.end(), 0);
if (dfs(u, v, v)) {
removeEdge(u, v);
removeEdge(v, u);
return 0;
}
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... |