# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897183 | Iwanttobreakfree | Traffic (IOI10_traffic) | C++14 | 5073 ms | 14940 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int cur_nodo, max_ans;
long long dfs(int nodoActual, vector<vector<int>>& lista, int par, int P[]) {
long long ans = 0;
int maxi = 0;
for (int vecino: lista[nodoActual]) {
if (vecino == par) continue;
int cur = dfs(vecino, lista, nodoActual, P);
ans += cur;
maxi = max(maxi, cur);
}
if (cur_nodo == nodoActual) max_ans = maxi;
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) {
cur_nodo = i;
long long cur = dfs(i, g, i, P);
if (max_ans < maxi) {
maxi = max_ans;
ans = i;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |