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"
#pragma GCC optimize("O3")
using namespace std;
int n;
vector< vector<int> > g;
vector<int> vis;
void initialize(int N){
n = N;
g.resize(n);
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++) if(i != j)
g[i].push_back(j);
}
int hasEdge(int u, int v) {
if(!binary_search(begin(g[u]), end(g[u]), v)) return 0;
vis.assign(n, 0);
deque<int> q;
q.push_back(u);
vis[u] = 1;
while(!q.empty()){
int w = q.front();
q.pop_front();
if(v == w){
g[u].erase(find(begin(g[u]), end(g[u]), v)), g[v].erase(find(begin(g[v]), end(g[v]), u));
return 0;
}
for(int x : g[w]) if(!vis[x] && (u!=w||v!=x)) vis[x] = 1, q.push_back(x);
}
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... |