# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
72618 | | vex | Game (IOI14_game) | C++14 | | 812 ms | 160208 KiB |
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 <bits/stdc++.h>
#define maxn 1505
using namespace std;
int n;
int sz[maxn],p[maxn],br[maxn][maxn];
void initialize(int N)
{
n=N;
for(int i=0;i<n;i++)
{
sz[i]=1;
p[i]=i;
}
for(int i=0;i<n;i++)for(int j=0;j<n;j++)br[i][j]=0;
}
int fnd(int x)
{
if(x==p[x])return x;
return p[x]=fnd(p[x]);
}
int hasEdge(int u,int v)
{
u=fnd(u);
v=fnd(v);
if(u==v)return 1;
if(sz[u]<sz[v])swap(u,v);
if(br[u][v]+1==sz[u]*sz[v])
{
sz[u]+=sz[v];
p[v]=p[u];
for(int i=0;i<n;i++)
{
if(i==u)continue;
br[u][i]+=br[v][i];
br[i][u]+=br[v][i];
}
return 1;
}
br[u][v]++;
br[v][u]++;
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... |