# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
109299 | PeppaPig | Beads and wires (APIO14_beads) | C++14 | 294 ms | 30952 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>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const int N = 2e5+5;
/*
0 - Parent edge any color, No node with 2 blue edges directed to its children
1 - Parent edge must be blue, No node with 2 blue edges directed to its children
2 - Parent edge any color, 1 node in subtree with 2 blue edges directed to its children
3 - Parent edge must be blue, 1 node in subtree with 2 blue edges directed to its children
*/
int n, dp[N][4];
vector<pii> g[N];
void dfs(int u, int p) {
for(pii v : g[u]) if(v.x != p) dfs(v.x, u);
vector<int> V, W, M;
vector<pii> D1, D2;
for(pii v : g[u]) if(v.x != p) {
V.emplace_back(v.x), W.emplace_back(v.y);
M.emplace_back(max(dp[v.x][0], dp[v.x][1] + v.y));
D1.emplace_back(dp[v.x][0] + v.y - M.back(), v.x);
D2.emplace_back(dp[v.x][2] + v.y - M.back(), v.x);
}
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... |