Algorithm: HDU 3586 Information Disturbing (tree DP + two points)

Source: Internet
Author: User

Meaning

For a tree n nodes, the node number is 1~n and the root node is 1. Each side is entitled to a value, cut off a side to spend cost (W)

To cut off some edges so that each leaf node can not go to the root node.

Request to cut off the sum of the costs can not exceed the case of M, so that each side to spend the upper limit as low as possible

Ideas

Two points can be chopped off the edge of the upper limit, and then the tree DP

F[i]: Represents the minimum cost of allowing all leaf nodes of the I subtree to reach the I point

F[i] = sum {min (w (i,v), f[v]) | V is son of I node}

And this problem has a upper limit weight, that is, the weight value is greater than the upper limit can not be cut.

So the shift over there needs to be changed.

if (w (i, v) > Upper limit) f[i] + = F[v];

else F[i] + = min (w (i,v), f[v]);

And then, if f[1]<=m, then this upper limit is eligible.

This problem, if initialized with the INF, then the INF must be greater than the maximum value of M 1000000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.