#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> P;
vector<vector<int>> adj;
int DFS(int u, int p, int root){
int max_traffic = 0, cur_traffic = P[u];
for(int v : adj[u]){
if(v == p) continue;
max_traffic = max(max_traffic, DFS(v, u, root));
cur_traffic += DFS(v, u, root);
}
if(u != root){
max_traffic = max(max_traffic, cur_traffic);
}
return max_traffic;
}
int find_arena(){
int arena = N, min_congestion = 2e9+1;
for(int root = 0; root < N; root++){
if(DFS(root, -1, root) < min_congestion){
arena = root;
min_congestion = DFS(root, -1, root);
}
}
// cout << min_congestion << endl;
return arena;
}
int LocateCentre(int N, int* F, int* S, int* D)
{
cin >> N;
adj.resize(N);
P.resize(N);
for(int i=0; i<N; i++)
P[i] = F[i];
for(int i=0; i<N-1; i++){
adj[S[i]].push_back(D[i]);
adj[D[i]].push_back(S[i]);
}
cout << find_arena() << endl;
}
Compilation message
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:53:1: warning: no return statement in function returning non-void [-Wreturn-type]
53 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |