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 <vector>
const int mxN = 1510;
int N, f[mxN], cnt[mxN][mxN];
int Find(int s){
if (f[s] == s) return s;
return f[s] = Find(f[s]);
}
bool Union(int u, int v){
u = Find(u); v = Find(v);
cnt[u][v]--;
cnt[v][u]--;
if (!cnt[u][v]){
for (int i = 0; i < N; i++){
cnt[u][i] += cnt[v][i];
cnt[i][u] += cnt[i][v];
}
f[v] = u;
return 1;
}
return 0;
}
void initialize(int n){
N = n;
for (int i = 0; i < N; i++){
f[i] = i;
for (int j = 0; j < N; j++)
if (i^j) cnt[i][j] = 1;
}
}
int hasEdge(int u, int v){ return Union(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... |