# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1082177 | logangd | 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 "game.h"
#include<set>
using namespace std;
int N,vs[1500],c=0;
set<int>ar[1500];
void initialize(int n) {
N=n;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(i!=j)ar[i].insert(j),ar[j].insert(i);
}
bool dfs(int u,int v){
if(u==v)return 1;
vs[u]=c;
for(auto i:ar[u])
if(vs[i]!=c)
if(dfs(i,v))return 1;
return 0;
}
int hasEdge(int u,int v){
c++;
ar[u].remove(v);
ar[v].remove(u);
if(dfs(u,v))return 0;
ar[u].insert(v);
ar[v].insert(u);
return 1;
}