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;
#define ii pair<int, int>
constexpr int MAX = 1569;
int n;
int ds[MAX];
int ctr[MAX][MAX];
inline int frep(int x) { return ds[x] == x ? x : ds[x] = frep(ds[x]); }
inline void join(int x, int y)
{
x = frep(x); y = frep(y);
if (x == y)
return;
for (int i = 0; i < n; ++i)
{
if (i == x || i == y)
continue;
ctr[i][x] += ctr[i][y];
ctr[x][i] += ctr[y][i];
}
ds[y] = x;
}
void initialize(int N) {
n = N;
for (int i = 0; i < n; ++i)
ds[i] = i;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
ctr[i][j] = 1;
}
int hasEdge(int u, int v) {
u = frep(u); v = frep(v);
if (ctr[u][v] > 1)
{
ctr[u][v]--; ctr[v][u]--;
return 0;
}
join(u, 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... |