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], cnt[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++)
{
rep[i] = i;
for (j=i+1; j<=n-1; j++) cnt[i][j] = 1;
}
}
int hasEdge(int u, int v) {
int i;
if (fd(u)>fd(v)) swap(u, v);
if (cnt[fd(u)][fd(v)] == 1)
{
// u gabung ke v aja
for (i=0; i<=n-1; i++) cnt[min(fd(v), i)][max(fd(v), i)] += cnt[min(fd(u), i)][max(fd(u), i)];
rep[fd(u)] = fd(v);
return 1;
}
cnt[fd(u)][fd(v)]--;
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... |