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 pa[1500], sz[1500];
bool assigned[1500][1500];
int fp(int u) { return pa[u] = (u == pa[u]) ? u : fp(pa[u]); }
void initialize(int N)
{
n = N;
for (int i=0 ; i<n ; i++)
{
pa[i] = i;
sz[i] = 1;
}
}
int hasEdge(int u, int v)
{
assigned[u][v] = assigned[v][u] = true;
int uu = fp(u), vv = fp(v);
if (uu == vv) return 0;
int cnt = 0;
for (int i=0 ; i<n ; i++) if (fp(i) == uu)
{
for (int j=i+1 ; j<n ; j++) if (fp(j) == vv)
{
if (assigned[i][j]) cnt += 1;
}
}
if (cnt != sz[uu] * sz[vv]) return 0;
pa[uu] = vv;
sz[vv] += sz[uu];
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... |