2019年2月25日

51nod 1673 树有几多愁——虚树+状压DP

摘要: 题目:http://www.51nod.com/Challenge/Problem.html#!#problemId=1673 建一个虚树。 一种贪心的想法是把较小的值填到叶子上,这样一个小值限制到的叶子比较少。 但不太会贪心了,所以考虑 DP 。只有 20 个叶子,(不是用来暴搜的!)可以状压DP 阅读全文

posted @ 2019-02-25 16:34 Narh 阅读(137) 评论(0) 推荐(0) 编辑

bzoj 3611(洛谷 4103) [Heoi2014]大工程——虚树

摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3611 https://www.luogu.org/problemnew/show/P4103 虚树的边权就是两端点的 dep 差。 求最短边可以像求最长边一样记录一个 d2[ cr ] 表示 阅读全文

posted @ 2019-02-25 13:09 Narh 阅读(125) 评论(0) 推荐(0) 编辑

bzoj 2286(洛谷 2495) [Sdoi2011]消耗战——虚树

摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2286 https://www.luogu.org/problemnew/show/P2495 学习(抄)了 hzwer 的代码,觉得写得很好。http://hzwer.com/6188.htm 阅读全文

posted @ 2019-02-25 11:17 Narh 阅读(189) 评论(0) 推荐(0) 编辑

LOJ 164 【清华集训2015】V——线段树维护历史最值

摘要: 题目:http://uoj.ac/problem/164 把操作改成形如 ( a,b ) 表示加上 a 之后对 b 取 max 的意思。 每个点维护当前的 a , b ,还有历史最大的 a , b 即 ma , mb 。 因为最后的答案是 tp[ x ] + ma , mb 中的一个,所以这样维护。 阅读全文

posted @ 2019-02-25 09:09 Narh 阅读(199) 评论(0) 推荐(0) 编辑

导航