# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
825250 | vjudge1 | Designated Cities (JOI19_designated_cities) | C++17 | 194 ms | 36764 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>
using namespace std;
// 123
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<vector<tuple<int, int, int>>> adj(n);
for (int i = 0; i < n - 1; i++) {
int u, v, a, b;
cin >> u >> v >> a >> b;
u--, v--;
adj[u].emplace_back(v, a, b);
adj[v].emplace_back(u, b, a);
}
vector<int64_t> f(n, 0);
function<void(int, int)> dfs1 = [&](int u, int p) {
for (auto [v, a, b] : adj[u]) { // a(u->v), b(v->u)
if (v == p) continue;
dfs1(v, u);
f[u] += a + f[v];
}
};
vector<int64_t> g(n, 0);
function<void(int, int)> dfs2 = [&](int u, int p) {
for (auto [v, a, b] : adj[u]) { // a(u->v), b(v->u)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |