# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
414502 |
2021-05-30T14:01:30 Z |
dxz05 |
Traffic (IOI10_traffic) |
C++14 |
|
14 ms |
23788 KB |
#include "traffic.h"
#include <vector>
using namespace std;
const int MAXN = 1e6 + 3e2;
vector<int> g[MAXN];
int cnt[MAXN];
void dfs(int v, int p){
for (int u : g[v]){
if (u != p){
dfs(u, v);
cnt[v] += cnt[u];
}
}
}
int LocateCentre(int N, int pp[], int S[], int D[]) {
for (int i = 0; i < N; i++) cnt[i] = pp[i];
for (int i = 0; i < N - 1; i++){
g[S[i]].push_back(D[i]);
g[D[i]].push_back(S[i]);
}
dfs(0, 0);
int mn = 2e9 + 5, ans = 0;
for (int i = 0; i < N; i++){
int cur = N - cnt[i];
for (int j : g[i]){
if (cnt[j] < cnt[i]) cur = max(cur, cnt[j]);
}
if (cur < mn) mn = cur, ans = i;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Incorrect |
14 ms |
23788 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Incorrect |
14 ms |
23788 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Incorrect |
14 ms |
23788 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
23756 KB |
Output is correct |
2 |
Incorrect |
14 ms |
23788 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |