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 <bits/stdc++.h>
#include "game.h"
using namespace std;
const int MAXN = 2000;
int cnt[MAXN][MAXN] , par[MAXN] , sz[MAXN];
void initialize(int n) {
for(int i = 0 ; i < MAXN ; i++){
fill(cnt[i] , cnt[i] + MAXN , 1);
par[i] = -1; sz[i] = 1;
}
}
int Find(int v){
return (par[v] == -1 ? v : par[v] = Find(par[v]));
}
void Union(int v , int u){
v = Find(v); u = Find(u);
if(sz[v] < sz[u]) swap(v , u);
par[u] = v; sz[v] += sz[u];
for(int i = 0 ; i < MAXN ; i++){
cnt[v][i] += cnt[u][i];
cnt[i][v] += cnt[i][u];
}
}
int hasEdge(int u, int v) {
u = Find(u); v = Find(v);
cnt[u][v]--; cnt[v][u]--;
if(cnt[v][u] > 0) return 0;
Union(v , u);
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |