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;
int cnt[1505][1505], par[1505], sz[1505], N;
int find(int u) {
if(u == par[u]) return u;
return par[u] = find(par[u]);
}
void initialize(int n) {
N = n;
for(int i=0; i<n; i++) par[i] = i, sz[i] = 1;
}
int hasEdge(int u, int v) {
u = find(u); v = find(v);
if(u == v) return 1;
if(sz[u] * sz[v] == cnt[u][v] + 1) {
if(sz[u] < sz[v]) swap(u, v);
sz[u] += sz[v];
par[v] = u;
for(int i=0; i<N; i++) {
cnt[u][i] += cnt[v][i];
cnt[i][u] += cnt[v][i];
}
return 1;
}
cnt[u][v]++; cnt[v][u]++;
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... |