Submission #897179

#TimeUsernameProblemLanguageResultExecution timeMemory
897179IwanttobreakfreeTraffic (IOI10_traffic)C++14
0 / 100
1 ms4540 KiB
#include <bits/stdc++.h> using namespace std; int dfs(int nodoActual, vector<vector<int>>& lista, int par, int P[]) { int ans = 0; for (int vecino: lista[nodoActual]) { if (vecino == par) continue; ans += dfs(vecino, lista, nodoActual, P); } return ans+P[nodoActual]; } int LocateCentre (int N, int P[], int S[], int D[]) { vector<vector<int>> g(N, vector<int>()); for (int i = 0; i < N-1; ++i) { g[S[i]].push_back(D[i]); g[D[i]].push_back(S[i]); } int maxi = 2e9+1, ans = -1; for (int i = 0; i < N; ++i) { int cur = dfs(i, g, i, P); if (cur < maxi) { maxi = cur; 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...