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

#TimeUsernameProblemLanguageResultExecution timeMemory
254239tatyamTraffic (IOI10_traffic)C++17
100 / 100
1291 ms129376 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; } int LocateCentre(int n, int p[], int s[], int d[]){ const int sum = accumulate(p, p + n, 0); vector<vector<int>> g(n); for(int i = 0; i < n - 1; i++){ const int a = s[i], b = d[i]; g[a].push_back(b); g[b].push_back(a); } vector<int> dp(n); auto dfs = [&](int from, int at, const auto& dfs) -> void { for(int i : g[at]) if(i != from){ dfs(at, i, dfs); p[at] += p[i]; chmax(dp[at], p[i]); } chmax(dp[at], sum - p[at]); }; dfs(-1, 0, dfs); return min_element(dp.begin(), dp.end()) - dp.begin(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...