# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
899537 | Iwanttobreakfree | Traffic (IOI10_traffic) | C++14 | 1 ms | 4440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) {
maxi = best_ans;
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... |