Submission #370899

#TimeUsernameProblemLanguageResultExecution timeMemory
370899XEMPLI5Traffic (IOI10_traffic)C++17
0 / 100
31 ms39532 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; int fans, mxN = 1e6; vector<vector<int>> g(mxN); vector<int> citySize(mxN), subTreeSize(mxN), maxTraffic(mxN), people(mxN); void dfs(int cur, int par){ subTreeSize[cur] = citySize[cur]; for(auto e: g[cur]) { if(e == par) return; dfs(e,par); subTreeSize[cur] += subTreeSize[e]; people[cur] = max(people[cur], subTreeSize[e]); } people[cur] = max(people[cur], fans - subTreeSize[cur]); } int LocateCentre(int n, int p[], int s[], int d[]){ for(int i=0; i<n; i++){ g[s[i]].push_back(d[i]); g[d[i]].push_back(s[i]); } for(int i=0; i<n; i++) { fans += p[i]; citySize[i] = p[i]; } dfs(0,0); int ans = 0, minPeople = 1e9; for(int i=0; i<n; i++){ if(people[i] < minPeople) { minPeople = people[i]; ans = i; } } 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...