# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
526179 | lkh3happy | Mechanical Doll (IOI18_doll) | C++14 | 0 ms | 0 KiB |
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 "split.h"
#include <bits/stdc++.h>
using namespace std;
int pa[100001], sz[100001], siz[100001], vis[100001], cnt[4];
vector<int> v[100001], ans;
vector<pair<int, int> > v1;
int find(int x){
if(pa[x]==-1) return x;
return pa[x]=find(pa[x]);
}
int uni(int x, int y){
x=find(x); y=find(y);
if(x==y) return 0;
sz[x]+=sz[y]; pa[y]=x;
return sz[x];
}
int getsz(int prev, int now){
int s=1;
for(auto &i:v[now]) if(prev!=i) s+=getsz(now, i);
return siz[now]=s;
}
int getct(int prev, int now, int n){
for(auto &i:v[now]) if(prev!=i && siz[i]>n/2) return getct(now, i, n);
return now;
}