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;
const int N = 1510;
int fat[N], sz[N];
int nedges[N][N];
int nn = 0;
void ini(int n) {
    for (int i = 0; i < n; ++i) fat[i] = i, sz[i] = 1;
}
int fnd (int x) {
    if (x == fat[x]) return x;
    return fat[x] = fnd(fat[x]);
}
void uni (int x, int y) { 
    int fx = fnd(x), fy = fnd(y);
    fat[fx] = fy;
    sz[fy] += sz[fx];
    for (int z = 0; z < nn; ++z) { 
        nedges[fy][z] += nedges[fx][z];
        nedges[z][fy] += nedges[z][fx];
    }
}
void initialize(int n) {
    nn = n;
    ini(n);
}
int hasEdge(int u, int v) {
    if (nedges[fnd(u)][fnd(v)] == sz[fnd(u)] * sz[fnd(v)] - 1) { 
        uni(u, v);
        return 1;
    }
    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... |