# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136158 | zoooma13 | Game (IOI14_game) | C++14 | 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 "game.h"
using namespace std;
#define MAX_N 1503
int n;
set <int> adj[MAX_N];
void initialize(int N) {
n = N;
for(int u=0; u<n; u++)
for(int v=u+1; v<n; v++){
adj[u].insert(v);
adj[v].insert(u);
}
}
int conn = 0;
bool vis[MAXN];
void dfs(int u){
vis[u] = 1;
conn++;
for(auto&v : adj[u]) if(!vis[v])
dfs(v);
}
int hasEdge(int u, int v) {
adj[u].erase(v);
adj[v].erase(u);
memset(vis ,0 ,sizeof vis);
conn = 0;
dfs(u);
if(conn == n)
return 0;
adj[u].insert(v);
adj[v].insert(u);
return 1;
}