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 <cstdio>
#include <cassert>
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
int ds[2000],siz[2000],num[2000][2000],tot;
void initialize(int n) {
tot=n;
for(int i=0;i<n;i++){
ds[i]=i;
siz[i]=1;
}
return;
}
int f(int x){
if(ds[x]!=x)return ds[x]=f(ds[x]);
return x;
}
int hasEdge(int u, int v) {
int a=f(u),b=f(v);
num[a][b]++;
num[b][a]++;
if(num[a][b]<(siz[a]*siz[b]))
return 0;
ds[b]=a;
siz[a]+=siz[b];
for(int i=0;i<tot;i++){
num[a][i]+=num[b][i];
num[i][a]+=num[b][i];
}
return 1;
}
/*
int read_int() {
int x;
assert(scanf("%d", &x) == 1);
return x;
}
int main() {
int n, u, v;
n = read_int();
initialize(n);
for (int i = 0; i < n * (n - 1) / 2; i++) {
u = read_int();
v = read_int();
printf("%d\n", hasEdge(u, v));
}
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... |