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>
using namespace std;
const int MAXN = 1600;
set<int> G[MAXN];
int cnt = 0;
bool visited[MAXN];
int nx;
void check(int v, int p){
cnt++;
visited[v] = 1;
for(auto u: G[v]){
if(u == p || visited[u]) continue;
check(u, v);
}
}
int hasEdge(int u, int v){
auto it = G[v].find(u);
if(it == G[v].end())
return 0;
G[v].erase(it);
G[u].erase(v);
cnt = 0;
for(int i = 0; i < nx; i++)
visited[i] = 0;
check(u, u);
if(cnt == nx) return 0;
G[v].insert(u);
G[u].insert(v);
return 1;
}
void initg(int n){
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
if(i != j) G[i].insert(j);
}
void initialize(int n){
initg(n);
nx = n;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |