제출 #655675

#제출 시각아이디문제언어결과실행 시간메모리
655675horiseunTraffic (IOI10_traffic)C++11
100 / 100
911 ms174604 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int v[1000005], sum, c[1000005], ch[1000005]; vector<int> adj[1000005]; void dfs(int x, int par) { for (int i : adj[x]) { if (i == par) continue; dfs(i, x); ch[x] += ch[i]; c[x] = max(c[x], ch[i]); } c[x] = max(c[x], sum - ch[x] - v[x]); ch[x] += v[x]; } int LocateCentre(int n, int p[], int s[], int d[]) { for (int i = 0; i < n; i++) { sum += p[i]; v[i] = p[i]; } for (int i = 0; i < n - 1; i++) { adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } dfs(0, -1); int m = 2e9 + 5, ans = -1; for (int i = 0; i < n; i++) { if (c[i] < m) { m = c[i]; ans = i; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...