
树形DP
creator平
期望破茧成蝶时的飞翔,向往突破蝉蛹后的鸣叫。
展开
-
POJ 2342 Anniversary party (树形dp入门)
There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tr...原创 2018-11-16 20:33:38 · 114 阅读 · 0 评论 -
hdu-1561 The more, The Better (树上背包)
ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗?Input每个测试实例首先包括2个整数,N,M.(1 <= M <= N <= 200)...原创 2018-11-21 20:03:22 · 126 阅读 · 0 评论 -
HDU - 1054 Strategic Game (树型DP)
Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a medieva...原创 2018-11-17 11:40:26 · 201 阅读 · 0 评论 -
hdu 2196 Computer
A school bought the first computer some time ago(so this computer's id is 1). During the recent years the school bought N-1 new computers. Each new computer was connected to one of settled earlier. Ma...原创 2018-11-19 20:53:54 · 136 阅读 · 0 评论 -
洛谷——P2015 二叉苹果树
题目连接:https://www.luogu.org/problem/P2015思路:树形DP入门/*每条边有一个权值,保留若干条边,求去掉边后根节点能够到达的所有边的权值和最大是多少*/#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;st...原创 2019-07-27 16:10:55 · 235 阅读 · 0 评论 -
UVA - 10859——Placing Lampposts
题目连接:https://vjudge.net/problem/UVA-10859题意:给出一个无向无环图,n个点,m条边,每再一个端点放置一个灯可以照亮相邻的边,求在放置最少灯且照亮所有边的情况下,被两盏灯照亮的边数应该尽量大。思路:本题转化为在求放置灯最少的情况下,一盏灯覆盖的边应该尽量小,则转化为x=aM+c,a为灯的数量,c为一盏灯覆盖的边数,M为一个大常数,如2000.这样转化为...原创 2019-08-06 11:21:57 · 146 阅读 · 0 评论