
树形DP专项
文章平均质量分 81
Veda_
这个作者很懒,什么都没留下…
展开
-
URAL 1018 Binary Apple Tree
DescriptionLet's imagine how apple tree looks in binary computer world. You're right, it looks just like a binary tree, i.e. any biparous branch splits up to exactly two new branches. We will en原创 2013-01-26 21:15:02 · 852 阅读 · 2 评论 -
POJ 3140
DescriptionIn the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and students will be able to compete at their own universities. However there’s one原创 2013-01-26 20:50:08 · 361 阅读 · 0 评论 -
POJ 1741 Tree 树的分治
题目大意:给你一棵树,边有权值,问距离不大于m的点有多少对。男人八题之五。。果然霸气。。最初的思路自然是O(n^2)求每对点的距离然后统计,不过这肯定会超时的。Pass。然后就用树形DP的思路了,选一个点为根节点向下递归,每递归到一点p,求都在以p为根的子树上,且不在同一以p的子节点为根的子树上且距离小于m的点对数。(也就是 最小公共祖先为p 且 距离小于m 的点对原创 2013-08-10 11:23:58 · 554 阅读 · 0 评论 -
Codeforces Round #294 (Div.2) E Shaass the Great
题目大意:有一棵树,n个节点,n-1条边,每条边有权值,保证树是强连通的。如果删掉一条边,在任意两个点之间建一条和该边权值相同的边(仍要保证是强连通的,可以与原节点相同),这时任意两点间的距离之和为sum。问sum最小为多少。枚举任意一条边,把该点删掉以后再新建一条边,假设把树分为左右两堆,可以发现sum分为三个部分。1. 左边任意两点的距离和。2. 右边任意两点的距离原创 2013-04-08 20:06:05 · 1196 阅读 · 0 评论