# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
941954 | 4QT0R | Race (IOI11_race) | C++17 | 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 <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> graph[200004];
bool usun[200004];
int siz[200004];
int ans=200004;
unordered_map<int,int> mp;
int dlugosc;
void prep(int v, int p){
siz[v]=1;
for (auto u : graph[v]){
if (u.first==p || usun[u.first])continue;
prep(u.first,v);
siz[v]+=siz[u.first];
}
}
int find_centr(int v, int p, int n){
int mx_pod=0,mx_son;
for (auto u : graph[v]){
if (u.first==p || usun[u.first])continue;
if (mx_pod<siz[u.first]){
mx_son=u.first;
mx_pod=siz[u.first];
};
}
if (mx_pod*2>n)return find_centr(mx_son,v,n);
else return v;