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>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
const int MAXN=1510;
int n, number[MAXN][MAXN], par[MAXN], si[MAXN];
int root(int a){
while(par[a]!=a) a=par[a]=par[par[a]];
return a;
}
void initialize(int N) {
n=N;
forn(i, n) par[i]=i, si[i]=1;
}
int hasEdge(int a, int b){
int ra=root(a), rb=root(b);
if(ra==rb) return 0;
if(si[ra]<si[rb]) swap(ra, rb);
if(si[ra]*si[rb]-1 == number[ra][rb]){
forn(i, n) number[i][ra]+=number[i][rb];
forn(i, n) number[ra][i]+=number[rb][i];
si[ra]+=si[rb];
par[rb]=ra;
return 1;
}
else{
number[ra][rb]++;
number[rb][ra]++;
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... |