# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1063480 | avighna | Roadside Advertisements (NOI17_roadsideadverts) | C++17 | 152 ms | 27392 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
std::cin >> n;
std::vector<std::vector<std::pair<ll, ll>>> adj(n);
for (ll i = 0, u, v, w; i < n - 1; ++i) {
std::cin >> u >> v >> w;
adj[u].push_back({v, w});
adj[v].push_back({u, w});
}
std::vector<std::vector<ll>> lift(n, std::vector<ll>(16));
std::vector<std::vector<ll>> lift_sum(n, std::vector<ll>(16));
std::vector<ll> depth(n);
std::function<void(ll, ll)> dfs;
dfs = [&](ll node, ll par) {
for (auto &[i, w] : adj[node]) {
if (i == par) {
continue;
}
lift[i][0] = node;
lift_sum[i][0] = w;
depth[i] = depth[node] + 1;
dfs(i, node);
Compilation message (stderr)
# | 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... |