#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> p;
vector <int> joke;
int N;
void initialize(int n)
{
N=n;
joke.assign(n, n-1);
p.resize(n);
for(int i=0; i<n; ++i)
{
p[i]=i;
}
}
int fgp(int a)
{
if(p[a]==a)
{
return a;
}
return p[a]=fgp(p[a]);
}
int hasEdge(int u, int v)
{
if(joke[fgp(u)]<=1 || joke[fgp(v)]<=1)
{
joke[fgp(v)]=max(joke[fgp(u)], joke[fgp(v)]);
p[fgp(u)]=fgp(v);
return 1;
}
--joke[fgp(u)];
--joke[fgp(v)];
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... |