Rare
0/6
DP on Trees - Combining Subtrees
Author: Benjamin Qi
Prerequisites
?
Status | Source | Problem Name | Difficulty | Tags | Solution |
---|---|---|---|---|---|
CF | Normal | Check CF |
This was the first problem I saw that involved this trick.
Solution
For two vectors and , define the vector to have entries for each .
Similar to the editorial, define to be the minimum cost to buy exactly goods out of the subtree of if we don't use the coupon for , and define to be the minimum cost to buy exactly goods out of the subtree of if we are allowed to use the coupon for . We update with one of the child subtrees of by setting , and similarly for .
Code
The editorial naively computes a bound of on the running time of this solution. However, this actually runs in !
Time Complexity of Merging Subtrees
This section is not complete.
Feel free to file a request to complete this using the "Contact Us" button.
add proof
Problems
Status | Source | Problem Name | Difficulty | Tags | Solution |
---|---|---|---|---|---|
COCI | Normal | ||||
CF | Normal | Check CF | |||
DMOJ | Normal | ||||
CF | Normal | Show TagsDP | |||
DMOJ | Hard | Show TagsNT |