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;
int N;
int par[1500];
int sz[1500];
int cnt[1500][1500];
int find_parent(int node)
{
if(par[node]==node)
{
return node;
}
return find_parent(par[node]);
}
void make_union(int node1,int node2)
{
node1=find_parent(node1);
node2=find_parent(node2);
if(sz[node1]<sz[node2])
{
swap(node1,node2);
}
sz[node1]+=sz[node2];
par[node2]=node1;
for(int i=0;i<N;i++)
{
cnt[node1][i]+=cnt[node2][i];
cnt[i][node1]+=cnt[i][node2];
}
}
void initialize(int n)
{
N=n;
for(int i=0;i<N;i++)
{
par[i]=i;
sz[i]=1;
}
}
int hasEdge(int u, int v)
{
u=find_parent(u);
v=find_parent(v);
assert(u!=v);
cnt[u][v]++;
cnt[v][u]++;
if(cnt[u][v]==sz[u]*sz[v])
{
make_union(u,v);
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... |