Submission #376909

#TimeUsernameProblemLanguageResultExecution timeMemory
37690954skyxenonTraffic (IOI10_traffic)C++11
0 / 100
16 ms23788 KiB
#include <iostream> #include <vector> using namespace std; #define ll long long vector<int> adj[1000000]; ll DFS(int P[], int src, int par) { ll ret = 0; for (auto x : adj[src]) { if (x != par) { ret += DFS(P, x, src); } } return P[src] + ret; } int LocateCentre(int N, int P[], int S[], int D[]) { ll minCongestion = 2000000000; int ans = -1; for (int i = 0; i < N; i++) { adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } for (int i = 0; i < N; i++) { ll congestionHere = 0; for (auto c : adj[i]) { congestionHere = max(congestionHere, DFS(P, c, i)); } if (congestionHere < minCongestion) { minCongestion = congestionHere; 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...