이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int const N = 1510;
int n, par[N], sz[N], cnt[N][N];
int find(int u) {
    return par[u] == -1 ? u : par[u] = find(par[u]);
}
int merge(int u, int v) {
    u = find(u), v = find(v);
    assert(u != v);
    if (sz[v] > sz[u])
        swap(u, v);
    if (++cnt[u][v] == sz[u] * sz[v]) {
        par[v] = u;
        sz[u] += sz[v];
        for (int w = 0; w < n; w++)
            cnt[u][w] += cnt[v][w], cnt[w][u] += cnt[w][v];
        return true;
    }
    return false;
}
void initialize(int _n) {
    n = _n;
    fill(par, par + n, -1);
    fill(sz, sz + n, 1);
}
int hasEdge(int u, int v) {
    return merge(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... |