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 <iostream>
#include <cstdio>
#include <set>
#include <vector>
#include <assert.h>
#include <memory.h>
using namespace std;
typedef pair<int,int> pii;
int dsu[2010],N;
int f[2010][2010];
int find(int u){
return dsu[u] == u ? u : dsu[u] = find(dsu[u]);
}
void initialize(int n) {
N = n;
for (int i = 0; i < n; ++i){
dsu[i] = i;
for(int j = 0 ; j < n ; j++){
if(i == j)
continue;
f[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
f[find(u)][find(v)]--;
f[find(v)][find(u)]--;
if(!f[find(u)][find(v)]){
int a = find(u);
int b = find(v);
for(int i = 0 ; i < N ; i++){
f[a][i] += f[b][i];
f[i][a] = f[a][i];
}
dsu[b] = a;
return true;
}
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... |