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;
const int N = 1500;
set<int> adj[N];
bool vis[N];
int n;
void dfs(int node, int par)
{
vis[node] = true;
for (int next : adj[node])
{
if (!vis[next]) dfs(next, node);
}
}
void initialize(int n1) {
n = n1;
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) {
adj[u].erase(v);
adj[v].erase(u);
for (int i = 0; i < n; i++)
{
vis[i] = false;
}
dfs(0, -1);
bool bridge = false;
for (int i = 0; i < n; i++)
{
if (!vis[i]) bridge = true;
}
if (!bridge) return 0;
adj[u].insert(v);
adj[v].insert(u);
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... |