(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #430665

#TimeUsernameProblemLanguageResultExecution timeMemory
430665haxormanTraffic (IOI10_traffic)C++14
100 / 100
1382 ms156828 KiB
#include "traffic.h" #include "bits/stdc++.h" using namespace std; const int mxN = 1e6 + 7; int n, p[mxN], dp[mxN], ans[mxN], tot; vector<int> graph[mxN]; void dfs(int u, int par) { dp[u] = p[u]; for (auto v : graph[u]) { if (v != par) { dfs(v, u); dp[u] += dp[v]; ans[u] = max(ans[u], dp[v]); } } } int LocateCentre(int N, int P[], int S[], int D[]) { n = N; for (int i = 0; i < n; ++i) { p[i] = P[i]; tot += p[i]; } for (int i = 0; i < n - 1; ++i) { graph[S[i]].push_back(D[i]); graph[D[i]].push_back(S[i]); } dfs(0, -1); int res = INT_MAX, city = 0; for (int u = 0; u < n; ++u) { int val = max(tot - dp[u], ans[u]); if (res > val) { res = val; city = u; } } return city; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...