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>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
using namespace std;
int pr[1501],gs[1501];
int ed[1501][1501];
int findleader(int x){
if(pr[x]==x){
return x;
}
return pr[x] = findleader(pr[x]);
}
int N;
void initialize(int n){
N = n;
for(int i = 0;i<=n;i++)pr[i] = i,gs[i] = 1;
}
int hasEdge(int a,int b){
a = findleader(a), b = findleader(b);
if(gs[a]<gs[b])swap(a,b);
if(gs[a]*gs[b]-1>ed[a][b]){
ed[a][b]++;
ed[b][a]++;
return 0;
}
gs[a]+=gs[b];
pr[b]=a;
for(int i = 0;i<N;i++){
ed[a][i]+=ed[b][i];
ed[i][a]+=ed[i][b];
}
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... |