# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
928592 |
2024-02-16T17:38:31 Z |
OAleksa |
Traffic (IOI10_traffic) |
C++14 |
|
12 ms |
33368 KB |
#include "traffic.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 69;
int dp[N], a[N], ans = 2e9 + 69, gas = -1;
vector<int> g[N];
void dfs(int v, int p) {
dp[v] = a[v];
for (auto u : g[v]) {
if (u == p)
continue;
dfs(u, v);
dp[v] += dp[u];
}
}
void solve(int v, int p) {
int mx = 0, s = 0;
for (auto u : g[v]) {
if (u == p)
continue;
s += dp[u];
mx = max(mx, dp[u]);
}
mx = max(mx, dp[1] - s);
if (mx <= ans) {
gas = v;
ans = mx;
}
for (auto u : g[v]) {
if (u == p)
continue;
solve(u, v);
}
}
int LocateCentre(int n, int p[], int u[], int v[]) {
for (int i = 0;i < n;i++)
a[i] = p[i];
for (int i = 0;i < n - 1;i++)
g[u[i]].push_back(v[i]);
dfs(1, 0);
solve(1, 0);
return gas;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
33368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
33368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
33368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
33368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |