![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
acm-dp
且将青衫换酒0
既然选择了这条路,即使粉身碎骨也要坚持下去。
展开
-
HDU2196 Computer(树形dp)
题目链接 题意 在n个结点的树中,边有权值,找到每个结点到最远的结点的距离 解法 有两种解法,一种是利用树的直径,另一种是树形dp 我的做法是树形dp的。 对于一个节点i来说,他最长的距离可以是向它的子树方向走,也可以向父节走, 如果向父节点走还有可能向父节点的子树走,因此需要注意的是父节点的子树包含了自己的子树,父节点有两种情况,父节点最长的路径没有经过i点和经过i点,没有经过i点则直接加上i到...原创 2020-01-07 19:33:45 · 87 阅读 · 0 评论 -
POJ 3107 Godfather (树形dp树的重心)
题目传送门 题意 有n个结点组成的无根树,找到树的重心。 思路 树的重心 一棵树的重心:在于重心相连的子树中节点最多的子树是与所有结点相连的子树中节点最多的子树的最小值 例如下面的树,结点一的子树可以分成三个,其中最大的子树有3个结点,是所有结点最大子树中最小的,所以结点1是一个重心 如果拿6来说,它的子树中最大的子树有5个结点并不是最小的 重心解释完了,就是用bfs遍历树,在遍历的时候计算每个...原创 2020-01-07 11:04:36 · 132 阅读 · 0 评论 -
CodeForces148D Bag of mice(概率dp)
Bag of mice The dragon and the princess are arguing about what to do on the New Year’s Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess th...原创 2020-01-06 21:15:29 · 95 阅读 · 0 评论 -
HDU4405 Aeroplane chess(期望dp)
区间dp原创 2020-01-06 21:01:24 · 82 阅读 · 0 评论 -
Discovering Gold(期望dp)
题目链接 You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially you are in position 1. Now each turn you throw a perfe...原创 2020-01-06 20:52:12 · 123 阅读 · 0 评论 -
Halloween Costumes (区间dp)
题目 题目链接 Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to attend as many parties as he can. Since it’s Halloween, these parties are all costume part...原创 2020-01-06 20:40:04 · 191 阅读 · 0 评论 -
Hdu 4632 Palindrome subsequence(区间dp)
题目 In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence <A...原创 2020-01-06 20:20:36 · 72 阅读 · 0 评论 -
Brackets(区间dp)
题目 We give the following inductive definition of a “regular brackets” sequence: the empty sequence is a regular brackets sequence, if s is a regular brackets sequence, then (s) and [s] are regular bra...原创 2020-01-06 20:12:16 · 71 阅读 · 0 评论