Algorithm: Hdu 4044 geodefense (Tree DP | Multi fork Tree to two fork tree)

Source: Internet
Author: User

Meaning

This is a tower defense game, the map is a n numbered 1~n node of the tree, node 1 is the enemy base, the other leaf nodes are your base.

The enemy base will continue to come out of the monster, in order to prevent the enemy from attacking your base, you can choose to build towers.

Each node can only build one tower, and the node I may have the Ki species tower for you to choose from, the price and attack the Price_i, respectively, Power_i

Attack Power_i, the effect is to let the enemy pass through this node when the enemy's blood reduced power_i point.

Then from the base of the enemy to the path of any one of your bases, the damage of all towers on this path is the resistance of this base.

The enemy's attack path is uncertain, and in order to protect all of your bases, you need to determine the lowest resistance in all bases.

You only have a quantity of M of money, ask the best plan, can resist the enemy's maximum blood volume is how much? That is, make the lowest resistance in all bases as large as possible,

How much is the biggest?

Ideas:

Method One: Multi fork turn two fork

Turn the fork tree into the expression of "left son, right brother" first. It will be found that a structure diagram is formed:

Multi-fork Tree:

Into the two-forked tree of "left son, right brother":

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.