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], cnt[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)
{
u = fp(u);
v = fp(v);
cnt[u][v] += 1;
cnt[v][u] += 1;
if (u == v) return 0;
if (cnt[u][v] != sz[u] * sz[v]) return 0;
for (int i=0 ; i<n ; i++)
{
cnt[u][i] += cnt[v][i];
cnt[i][u] += cnt[i][v];
}
pa[v] = u;
sz[u] += sz[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... |