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

#TimeUsernameProblemLanguageResultExecution timeMemory
314852LethalPuppyTraffic (IOI10_traffic)C++17
100 / 100
1300 ms126328 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; const int N = 1e6+5; vector<int> neighbours[N]; int fans[N], total = 0, res = 0, traffic[N], posans[N], nums = 2e9+1; void dfs(int u, int v) { for (auto &x: neighbours[u]) { if (x == v) continue; dfs(x, u); traffic[u] += traffic[x]; posans[u] = max(posans[u], traffic[x]); } posans[u] = max(posans[u], total - traffic[u] - fans[u]); traffic[u] += fans[u]; } int LocateCentre(int n, int p[], int s[], int d[]) { for (int i = 0; i < n - 1; ++i) { neighbours[s[i]].push_back(d[i]), neighbours[d[i]].push_back(s[i]); fans[i] = p[i], total += p[i]; } fans[n - 1] = p[n - 1], total += p[n - 1]; dfs(0, -1); for (int i = 0; i < n; ++i) { if (nums > posans[i]) { nums = posans[i]; 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...