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