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;
constexpr int nax = 81;
int N;
set<int> adj[nax];
set<int> curr[nax];
bool vis[nax];
int cnt = 0;
void reset() {
for(int i = 0; i < N; i++) {
vis[i] = false;
}
cnt = 0;
}
void dfs(int v, bool all_y) {
vis[v] = true;
cnt++;
for(int u : curr[v]) {
if (!vis[u]) {
dfs(u, all_y);
}
}
if (all_y) {
for(int u : adj[v]) {
if (!vis[u]) {
dfs(u, all_y);
}
}
}
}
bool dfs() {
reset();
dfs(0, false);
if (cnt == N) {
return false;
}
reset();
dfs(0, true);
if (cnt != N) {
return false;
}
return true;
}
void initialize(int n) {
N = n;
// curr + all Yes -> form full
// curr + all No -> not form full
for(int i = 0; i < n; i++) {
for(int j = i+1; j < n; j++) {
adj[i].insert(j);
adj[j].insert(i);
}
}
}
int hasEdge(int u, int v) {
if (u > v) {
swap(u, v);
}
adj[u].erase(v);
adj[v].erase(u);
curr[u].insert(v);
curr[v].insert(u);
if (!dfs()) {
curr[u].erase(v);
curr[v].erase(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... |