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

#TimeUsernameProblemLanguageResultExecution timeMemory
292437shrek12357Traffic (IOI10_traffic)C++14
100 / 100
1237 ms171000 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> #include "traffic.h" using namespace std; const int MAXN = 1e6+5; vector<int> edges[MAXN]; int best = INT_MAX; int ans = 0; int totSum = 0; int subtree[MAXN]; int vals[MAXN]; void dfs(int src, int par) { int val = 0; int curSum = vals[src]; for (auto i : edges[src]) { if (i == par) { continue; } dfs(i, src); val = max(val, subtree[i]); curSum += subtree[i]; } val = max(val, totSum - curSum); if (val < best) { best = val; ans = src; } subtree[src] = curSum; } int LocateCentre(int n, int p[MAXN], int s[MAXN], int d[MAXN]) { for (int i = 0; i < n; i++) { totSum += p[i]; vals[i] = p[i]; subtree[i] = 0; if (i != n - 1) { edges[s[i]].push_back(d[i]); edges[d[i]].push_back(s[i]); } } dfs(0, 0); 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...