#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
const int maxn=1510;
int n;
vi head(maxn);
vi emptyneig(maxn);
int get(int a) {
return (a==head[a]?a:head[a]=get(head[a]));
}
void initialize(int _n) {
n=_n;
iota(all(head),0);
fill(all(emptyneig),n-1);
}
int hasEdge(int u, int v) {
int hu=get(u);
int hv=get(v);
if (hu==hv) {
return 0;
}
emptyneig[hu]--;
emptyneig[hv]--;
if (emptyneig[hu]==0 || emptyneig[hv]==0) {
head[hu]=hv;
emptyneig[hv]+=emptyneig[hu];
return 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |