Submission #414868

#TimeUsernameProblemLanguageResultExecution timeMemory
414868JediMaster11Traffic (IOI10_traffic)C++17
50 / 100
5055 ms28200 KiB
#include <bits/stdc++.h> #include "traffic.h" using namespace std; const int MAX_N = 1e6 + 3e2; vector<int> adj[MAX_N]; int dfs(int u, int p, int P[]) { int ans = P[u]; for(int to : adj[u]) { if(to == p) continue; ans += dfs(to, u, P); } return ans; } int LocateCentre(int N, int P[], int S[], int D[]) { for(int i = 0; i < N-1; i++) { adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } int ans = 2147483647, ret = -1; for(int i = 0; i < N; i++) { int max_traffic = -2147483648; for(int to : adj[i]) { max_traffic = max(max_traffic, dfs(to, i, P)); } if(max_traffic < ans) { ans = max_traffic; ret = i; } } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...