# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
899538 | Iwanttobreakfree | Traffic (IOI10_traffic) | C++14 | 825 ms | 167144 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 best_ans = 2e9+2, nodo_final = -1;
int total_residents;
int dfs(int nodoActual, vector<vector<int>>& lista, int par, int P[]) {
// ans cuenta los residentes del subarbol
// maxi se quedara con la maxima afluencia de cada vecino
int total_subtree_residents = P[nodoActual], maxi = 0;
for (int vecino: lista[nodoActual]) {
if (vecino == par) continue;
int subtree_resi = dfs(vecino, lista, nodoActual, P);
total_subtree_residents += subtree_resi;
maxi = max(maxi, subtree_resi);
}
maxi = max(maxi, total_residents-total_subtree_residents);
// Restamos el total menos el subtree y sabremos cuantos llegan
// por el padre
if (maxi < best_ans) {
best_ans = maxi;
nodo_final = nodoActual;
}
return total_subtree_residents;
}
int LocateCentre (int N, int P[], int S[], int D[]) {
vector<vector<int>> g(N, vector<int>());
vector<int> subtreeSz(N);
for (int i = 0; i < N-1; ++i) {
g[S[i]].push_back(D[i]);
g[D[i]].push_back(S[i]);
# | 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... |