Submission #897180

#TimeUsernameProblemLanguageResultExecution timeMemory
897180IwanttobreakfreeTraffic (IOI10_traffic)C++11
0 / 100
1 ms4440 KiB
#include <bits/stdc++.h> using namespace std; long long dfs(int nodoActual, vector<vector<int>>& lista, int par, int P[]) { long long 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]); } long long maxi = 2e18+1, ans = -1; for (int i = 0; i < N; ++i) { long long 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...