(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 #308288

#TimeUsernameProblemLanguageResultExecution timeMemory
308288TemmieTraffic (IOI10_traffic)C++17
100 / 100
1260 ms153208 KiB
#include "traffic.h" #include <bits/stdc++.h> std::vector <std::vector <int>> g; std::vector <int> ans, sms; int sum = 0; void dfs(int val[], int node = 0, int par = -1) { sms[node] = val[node]; for (int x : g[node]) if (x != par) { dfs(val, x, node); sms[node] += sms[x]; ans[node] = std::max(ans[node], sms[x]); } ans[node] = std::max(ans[node], sum - sms[node]); } int LocateCentre(int n, int val[], int u[], int v[]) { for (int i = 0; i < n; i++) sum += val[i]; g.resize(n); ans.resize(n, 0); sms.resize(n, 0); for (int i = 0; i < n - 1; i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(val); int ansind = 0, best = INT_MAX; for (int i = 0; i < n; i++) { if (ans[i] < best) { best = ans[i]; ansind = i; } } return ansind; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...