Submission #851510

#TimeUsernameProblemLanguageResultExecution timeMemory
851510abcvuitunggioTraffic (IOI10_traffic)C++17
100 / 100
666 ms170832 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; vector <int> ke[1000001]; long long sz[1000001]; void dfs(int u, int p){ for (int v:ke[u]) if (v!=p){ dfs(v,u); sz[u]+=sz[v]; } } int centroid(int u, int p){ for (int v:ke[u]) if (v!=p&&sz[v]*2>sz[0]) return centroid(v,u); return u; } int LocateCentre(int N, int pp[], int S[], int D[]) { for (int i=0;i<N-1;i++){ ke[S[i]].push_back(D[i]); ke[D[i]].push_back(S[i]); } for (int i=0;i<N;i++) sz[i]=pp[i]; dfs(0,0); return centroid(0,0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...