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>
using namespace std;
int N;
int p[2000];
int ss[2000];
set<pair<int, int>> s;
vector<pair<int, int>> g;
void initialize(int n)
{
N = n;
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
s.insert({i, j});
}
}
}
int get(int x)
{
return (p[x] == x ? x : p[x] = get(p[x]));
}
void meg(int x, int y)
{
x = get(x);
y = get(y);
if(x != y){
p[y] = x;
ss[x] += ss[y];
}
}
int hasEdge(int u, int v)
{
for(int i = 0; i < N; i++){
p[i] = i;
ss[i] = 1;
}
for(auto x : g){
meg(x.first, x.second);
}
if(u > v)swap(u, v);
s.erase({u, v});
for(auto x : s){
meg(x.first, x.second);
}
if(ss[get(1)] == N){
return 0;
}
g.push_back({u, v});
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... |