Submission #403159

#TimeUsernameProblemLanguageResultExecution timeMemory
403159NafeeszxTraffic (IOI10_traffic)C++14
0 / 100
22 ms35504 KiB
#include <bits/stdc++.h> using namespace std; #define trav(a, x) for(auto& a : x) const int MX = 1e6; vector<int> adj[MX]; vector<int> nodes(MX); vector<int> children(MX); vector<int> people(MX, 0); int citizen = 0; void dfs(int u, int p){ trav(v, adj[u]){ if(v != p){ dfs(v, u); children[u] += children[v]; people[u] = max(people[u], children[v]); } } people[u] = max(people[u], citizen - children[u] - nodes[u]); children[u] += nodes[u]; } int LocateCentre(int n, int p[], int s[], int d[]){ for(int i = 0; i < n; ++i){ nodes[i] = p[i]; citizen += p[i]; } for(int i = 0; i < n - 1; ++i){ adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } int minpeople = 2e9 + 1, res = 0; for(int i = 0; i < n; ++i){ if(people[i] < minpeople){ res = i; minpeople = people[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...