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>
#include "game.h"
using namespace std;
int n, rep[1569];
bool ex[1569][1569];
int fd(int x)
{
if (rep[x] != x) rep[x] = fd(rep[x]);
return rep[x];
}
void initialize(int n)
{
::n = n;
int i, j;
for (i=0; i<=n-1; i++)
{
for (j=i+1; j<=n-1; j++) ex[i][j] = 1;
}
}
int hasEdge(int u, int v) {
int i, j;
if (u>v) swap(u, v);
ex[u][v] = 0;
for (i=0; i<=n-1; i++) rep[i] = i;
for (i=0; i<=n-1; i++)
{
for (j=i+1; j<=n; j++)
{
if (ex[i][j]) rep[fd(i)] = fd(j);
}
}
if (fd(u) != fd(v)) ex[u][v] = 1;
return ex[u][v];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |