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>
#define N 1505
using namespace std;
int par[N];
int out[N];
int n;
bool vis[N];
set<int> adj[N];
void dfs(int v){
vis[v] = 1;
for(auto u:adj[v]){
if(vis[u])continue;
dfs(u);
}
}
int find(int a){
if(a == par[a])return a;
return par[a] = find(par[a]);
}
void initialize(int _n) {
n = _n;
for(int i = 0;i<n;i++){
for(int j = 0;j<n;j++){
if(i == j)continue;
adj[i].insert(j);
}
par[i] = i;
out[i] = n-1;
}
}
int hasEdge(int u, int v) {
if(u > v)swap(u,v);
adj[u].erase(v);
adj[v].erase(u);
dfs(0);
bool ok = 1;
for(int i = 0;i<n;i++){
ok &= vis[i];
vis[i] = 0;
}
if(ok){
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... |