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=1510;
int deg[N][N], p[N], srank[N];
int n;
void initialize(int NC)
{
n=NC;
for(int i=1;i<=n;i++)
{ for(int j=1;j<=n;j++) deg[i][j]=0;
srank[i]=1;p[i]=i;
}
}
int find(int x)
{
if(p[x]!=x) p[x]=find(p[x]);
return p[x];
}
void UNION(int a, int b)
{
if(srank[a]<srank[b]) swap(a, b);
srank[a]+=srank[b];p[b]=a;
for(int i=1;i<=n;i++) deg[a][i]+=deg[b][i];
for(int i=1;i<=n;i++) deg[i][a]=deg[a][i];
}
int hasEdge(int u, int v)
{
u++;v++;
int tu=find(u), tv=find(v);
int tot=srank[tu]*srank[tv];deg[tu][tv]++;deg[tv][tu]++;
if(deg[tu][tv]==tot)
{
UNION(tu, tv);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... |