# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
857983 | Trisanu_Das | Village (BOI20_village) | C++17 | 86 ms | 22864 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.
//AE86!!!!
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
int n,u,v,cnt=1,h1[N],h2[N],sz[N],seq[N],lv[N],P[20][N];
ll ans1,ans2;
vector<int> adj[N];
void A1(int u,int p){
for(auto v : adj[u]){
if(v == p) continue;
A1(v,u);
}
if(h1[u] == u){
if(u == 1) swap(h1[u],h1[adj[1][0]]);
else swap(h1[u],h1[p]);
ans1 += 2;
}
}
int size(int u,int p){
sz[u] = 1;
for(auto v : adj[u]) if(v != p) sz[u] += size(v,u);
return sz[u];
}
int find_cen(int u,int p,int all){
for(auto v : adj[u]) if(v != p && sz[v] > n/2) return find_cen(v,u,all);
return u;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |