动态规划-树形DP
___Evan
这个作者很懒,什么都没留下…
展开
-
POJ-Rebuilding Roads 树形DP
#include #include #include #include #include #include #include #include #include using namespace std; const int maxn = 155; const int inf = 1<<29; typedef __int64 LL; int n,p; int dp[maxn][maxn]; //d原创 2014-04-09 21:21:33 · 385 阅读 · 0 评论 -
HDU-1520 简单树形dp
http://acm.hdu.edu.cn/showproblem.php?pid=1520 dp[i][1] 表示选择i点 dp[i][0]表示不选择i点 #include #include #include #include using namespace std; const int maxn = 6005; int n; int w[maxn],dp[maxn]原创 2013-10-17 17:58:04 · 498 阅读 · 0 评论 -
树形DP总结
列出一些经典问题吧: 1:给出一棵树 每个节点有权值 要求父节点和子节点不能同时取 求能够取得的最大值 (hdu1520) 2:给出一棵树,求离每个节点最远的点的距离 (hdu2196) 3:1>在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡转载 2013-10-17 14:04:07 · 636 阅读 · 2 评论