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 mat[N][N];
int par[N], n_, sz[N];
int getPar(int v) {
return par[v] == v ? v : par[v] = getPar(par[v]);
}
void initialize(int n) {
n_ = n;
iota(par, par + n , 0);
memset(mat , 0 , sizeof(mat));
fill(sz , sz + n , 1);
}
int hasEdge(int u, int v) {
u = getPar(u);
v = getPar(v);
mat[u][v]++;
mat[v][u]++;
if (mat[u][v] == sz[u] * sz[v]) {
par[u] = v;
sz[v] += sz[u];
for (int i = 0 ; i < n_; i++)
if (par[i] == i) {
mat[i][v] += mat[i][u];
mat[v][i] += mat[i][u];
}
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... |