# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
235892 | Bilyana | Game (IOI14_game) | C++17 | 0 ms | 0 KiB |
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 "grader.h"
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<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;
}