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;
const int N=15e2;
int nn;
int cnt[N+10][N+10];
int fau[N+10];
int f(int x)
{
if(fau[x]!=x)
fau[x]=f(fau[x]);
return fau[x];
}
void un(int x,int y)
{
x=f(x);
y=f(y);
for(int i=0;i<nn;i++)
cnt[x][i]=cnt[i][x]=cnt[x][i]+cnt[y][i];
fau[y]=x;
return;
}
void initialize(int n)
{
nn=n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cnt[i][j]=1;
fau[i]=i;
}
return;
}
int hasEdge(int u,int v)
{
u=f(u);v=f(v);
//cerr<<u<<" "<<v<<"\n";
if(cnt[u][v]>1)
{
cnt[u][v]--;
cnt[v][u]--;
return 0;
}
un(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... |