HDU-1011 Starship Troopers(树形dp)】的更多相关文章

Starship Troopers Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17498    Accepted Submission(s): 4644 Problem Description You, the leader of Starship Troopers, are sent to destroy a base of t…
本来是一道很水的树形DP题 设dp[i][j]表示,带着j个人去攻打以节点i为根的子树的最大收益 结果wa了一整晚 原因: 坑点1: 即使这个节点里面没有守卫,你如果想获得这个节点的收益,你还是必须派一个人去这个节点,不然谁帮你去拿收益? 坑点2: 题目说是从节点1开始攻打,然后我就以为给出的数据都是以1为根节点的,就没有加双向边 不过, 最后我加了双向边,然后还是wa了 又找了很久,最后发现是前向星的数组开小了 注意:数组开小了可能会返回wa,tle,re等等等等 #include<cstdi…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1011 dp[u][i]为以u为根节点的,花了不超过i元钱能够得到的最大价值 因为题目里说要访问子节点必须先访问根节点,所以 dp[u][i+j] = max(dp[u][i],dp[u][i]+dp[v][j]); v是u的儿子节点. 代码: import java.util.*; import static java.lang.Math.*; class Graph{ ArrayList<Arra…
Starship Troopers Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description You, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a h…
Starship Troopers Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20833    Accepted Submission(s): 5550 Problem Description   You, the leader of Starship Troopers, are sent to destroy a base of…
http://acm.hdu.edu.cn/showproblem.php?pid=1011   题意:每个节点有两个值bug和brain,当清扫该节点的所有bug时就得到brain值,只有当父节点被清空时,才可以清扫它          的子节点,而清扫需要一定的人员.给定M个人员,N个结点的树,求最大brain和   这看起来是一道非常简单的背包dp 但是 写完提交wa之后,我发现这道题,并不简单!因为他的题意并不是完全和我找到的题意一样(我承认我语文很差劲所以随便找个题解看题意..),题目…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1011 题意: 题目大意是有n个房间组成一棵树,你有m个士兵,从1号房间开始让士兵向相邻的房间出发,每个房间里有一个代价,代价是值/20个士兵, 同时有一个价值,问你花费这m个士兵可以得到的最大价值是多少. 思路: 树上背包,这题比较坑爹.士兵为0,输出0.要是一个房间的cost不足20的倍数也要补全20的倍数. dp[i][j]表示以i节点为子树的root使用j个士兵的最大价值( 不用管父节点 ),…
You, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consists of many rooms connected with tunnels. Each room is occupied by some bugs, and their brains hide…
Starship Troopers Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8540    Accepted Submission(s): 2379 Problem Description You, the leader of Starship Troopers, are sent to destroy a base of t…
Starship Troopers Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19362 Accepted Submission(s): 5130 Problem Description You, the leader of Starship Troopers, are sent to destroy a base of the bu…