acm-dp
且将青衫换酒0
既然选择了这条路,即使粉身碎骨也要坚持下去。
展开
-
HDU2196 Computer(树形dp)
题目链接题意在n个结点的树中,边有权值,找到每个结点到最远的结点的距离解法有两种解法,一种是利用树的直径,另一种是树形dp我的做法是树形dp的。对于一个节点i来说,他最长的距离可以是向它的子树方向走,也可以向父节走,如果向父节点走还有可能向父节点的子树走,因此需要注意的是父节点的子树包含了自己的子树,父节点有两种情况,父节点最长的路径没有经过i点和经过i点,没有经过i点则直接加上i到...原创 2020-01-07 19:33:45 · 86 阅读 · 0 评论 -
POJ 3107 Godfather (树形dp树的重心)
题目传送门题意有n个结点组成的无根树,找到树的重心。思路树的重心一棵树的重心:在于重心相连的子树中节点最多的子树是与所有结点相连的子树中节点最多的子树的最小值例如下面的树,结点一的子树可以分成三个,其中最大的子树有3个结点,是所有结点最大子树中最小的,所以结点1是一个重心如果拿6来说,它的子树中最大的子树有5个结点并不是最小的重心解释完了,就是用bfs遍历树,在遍历的时候计算每个...原创 2020-01-07 11:04:36 · 127 阅读 · 0 评论 -
CodeForces148D Bag of mice(概率dp)
Bag of miceThe 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 · 93 阅读 · 0 评论 -
HDU4405 Aeroplane chess(期望dp)
区间dp原创 2020-01-06 21:01:24 · 75 阅读 · 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 · 119 阅读 · 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 · 182 阅读 · 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 · 66 阅读 · 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 · 69 阅读 · 0 评论