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;
long long n,dsu[1569],cc[1569],am[1569][1569];
long long fd(long long x)
{
if(dsu[x]!=x)
{
dsu[x]=fd(dsu[x]);
}
return dsu[x];
}
void initialize(int on)
{
long long i;
n=on;
for(i=0;i<n;i++)
{
dsu[i]=i;
cc[i]=1;
}
}
int hasEdge(int x,int y)
{
long long i;
x=fd(x);
y=fd(y);
am[x][y]++;
am[y][x]++;
if(am[x][y]<cc[x]*cc[y])
{
return 0;
}
else
{
am[x][y]=0;
am[y][x]=0;
for(i=0;i<n;i++)
{
am[x][i]+=am[y][i];
am[i][x]+=am[i][y];
}
cc[x]+=cc[y];
dsu[y]=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... |