# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
745172 |
2023-05-19T13:45:18 Z |
Desh03 |
Traffic (IOI10_traffic) |
C++17 |
|
1 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> sz, a;
int ans = INT_MAX;
void dfs(int u, int p) {
sz[u] = a[u];
for (int v : g[u])
if (v ^ p)
dfs(v, u), sz[u] += sz[v];
}
void solve(int u, int p) {
int x = sz[0] - sz[u];
for (int v : g[u])
if (v ^ p)
solve(v, u), x = max(x, sz[v]);
ans = min(ans, x);
}
int LocateCentre(int n, int p[], int s[], int d[]) {
g.resize(n);
for (int i = 0; i < n; i++) a[i] = p[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);
solve(0, 0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |