
树形dp
lqybzx
123
展开
-
bzoj 2286: [Sdoi2011]消耗战
Description在一场战争中,战场由n个岛屿和n-1个桥梁组成,保证每两个岛屿间有且仅有一条路径可达。现在,我军已经侦查到敌军的总部在编号为1的岛屿,而且他们已经没有足够多的能源维系战斗,我军胜利在望。已知在其他k个岛屿上有丰富能源,为了防止敌军获取能源,我军的任务是炸毁一些桥梁,使得敌军不能到达任何能源丰富的岛屿。由于不同桥梁的材质和结构不同,所以炸毁不同的桥梁有不同的代价,我军希原创 2017-07-18 10:39:44 · 258 阅读 · 0 评论 -
zoj 3949 Edge to the Root 2017浙大校赛B
Given a tree with n vertices, we want to add an edge between vertex 1 and vertex x, so that the sum of d(1, v) for all vertices v in the tree is minimized, where d(u, v) is the minimum number of edg原创 2017-04-13 20:53:31 · 1097 阅读 · 0 评论 -
hdu 5723 Abandoned country
Problem DescriptionAn abandoned country has n(n≤100000) villages which are numbered from 1 to n. Since abandoned for a long time, the roads need to be re-built. There are m(m≤1000000) roads原创 2017-04-13 20:44:28 · 315 阅读 · 0 评论 -
hdu 5886 Tower Defence 2016ACM/ICPC青岛赛区网络赛1009
Problem DescriptionThere was a civil war between two factions in Skyrim, a province of the Empire on the continent of Tamriel. The Stormcloaks, led by Ulfric Stormcloak, are made up of Skyrim's na原创 2016-09-18 21:11:43 · 932 阅读 · 0 评论 -
2016中国大学生程序设计竞赛 - 网络选拔赛 1003 Magic boy Bi Luo with his excited tree hdu5834
Problem DescriptionBi Luo is a magic boy, he also has a migic tree, the tree has N nodes , in each node , there is a treasure, it's value is V[i], and for each edge, there is a cost C[i], wh原创 2016-08-14 23:02:25 · 851 阅读 · 0 评论 -
bzoj 4033: [HAOI2015]T1
Description有一棵点数为 N 的树,树边有边权。给你一个在 0~ N 之内的正整数 K ,你要在这棵树中选择 K个点,将其染成黑色,并将其他 的N-K个点染成白色 。 将所有点染色后,你会获得黑点两两之间的距离加上白点两两之间的距离的和的受益。问受益最大值是多少。Input 第一行包含两个整数 N, K 。接下来 N-1 行每行三个正整数 fr,原创 2015-05-21 22:02:56 · 1087 阅读 · 0 评论 -
bzoj 1907: 树的路径覆盖
DescriptionInputOutputSample Input171 22 32 44 65 66 7Sample Output3HINTSourcePlay with Tree By Amber自己写了一发贪心WA了。。然后去看题解f[i]表示i为子树的最小路原创 2015-02-23 19:20:58 · 1055 阅读 · 0 评论 -
bzoj 2314: 士兵的放置
Description八中有N个房间和N-1双向通道,任意两个房间均可到达.现在出了一件极BT的事,就是八中开始闹鬼了。老大决定加强安保,现在如果在某个房间中放一个士兵,则这个房间以及所有与这个房间相连的房间都会被控制.现在老大想知道至少要多少士兵可以控制所有房间.以及有多少种不同的方案数. Input 第一行一个数字N,代表有N个房间,房间编号从1开始原创 2015-02-21 16:58:13 · 1017 阅读 · 0 评论 -
bzoj 1131: [POI2008]Sta
Description给出一个N个点的树,找出一个点来,以这个点为根的树时,所有点的深度之和最大Input给出一个数字N,代表有N个点.NOutput输出你所找到的点,如果具有多个解,请输出编号最小的那个.Sample Input81 45 64 56 76 82 43 4Sample Output7原创 2015-01-31 22:27:33 · 1144 阅读 · 0 评论 -
bzoj 3611: [Heoi2014]大工程
Description国家有一个大工程,要给一个非常大的交通网络里建一些新的通道。 我们这个国家位置非常特殊,可以看成是一个单位边权的树,城市位于顶点上。 在 2 个国家 a,b 之间建一条新通道需要的代价为树上 a,b 的最短路径。 现在国家有很多个计划,每个计划都是这样,我们选中了 k 个点,然后在它们两两之间 新建 C(k,2)条 新通道。现在对于每个计划,我们想知道原创 2017-07-18 13:26:05 · 333 阅读 · 0 评论