Submission #491611

#TimeUsernameProblemLanguageResultExecution timeMemory
491611vendx_greybackTraffic (IOI10_traffic)C++14
0 / 100
13 ms23788 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() typedef pair<int,int> ppi; typedef vector<int> vi; typedef vector<vector<int>> vvi; const int mxn = 1e6; vi adj[mxn]; int sz[mxn]; int mx[mxn]; void dfs(int u, int p){ for(auto v: adj[u]){ if(v == p) continue; dfs(v, u); sz[u] += sz[v]; mx[u] = max(mx[u], sz[v]); } } int LocateCentre(int n, int p[], int s[], int d[]){ for(int i = 0; i < n-1; i++){ adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } int total = 0; for(int i = 0; i < n; i++){ sz[i] = p[i]; total += p[i]; } dfs(0, -1); int wt = mxn + 10; int res = -1; for(int i = 0; i < n; i++){ int temp = max(mx[i], total - sz[i]); if(temp < wt){ wt = temp; res = i; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...