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>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define vp vector<pii>
using namespace std;
const int N=1506;
int sz[N]{0},del[N]{0},pr[N]{0},m;
int get(int r){
return pr[r]==r?r:pr[r]=get(pr[r]);
}
void initialize(int n){
iota(pr,pr+n,0);m=n;
for(int i=0;i<n;i++)sz[i]=1,del[i]=0;
}
int hasEdge(int u,int v){
int a=get(u),b=get(v);
if(a==b)return 1;
if(del[a]<sz[a]*(m-sz[a])&&del[b]<sz[b]*(m-sz[b])){del[a]++,del[b]++;return 0;}
else {sz[a]+=sz[b],del[a]+=del[b],pr[b]=a;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... |