poj2342 Anniversary party (树形dp) Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9128   Accepted: 5250 Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarc…
转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4316097.html   ---by 墨染之樱花 [题目链接]http://poj.org/problem?id=2342 [题目描述]一个企业有N个员工,每个人都有一个表示欢乐度的数值.现在要开一场party,不过这些员工里面有上下级关系,每个员工都不希望见到自己的直接上司,即每个员工都不能和直接上司同时出现.求这场party到场的人的总欢乐度的最大值 [思路]最基础的树形dp,现根据上下…
Anniversary party Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3862   Accepted: 2171 Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure…
动态规划作为一种求解最优方案的思想,和递归.二分.贪心等基础的思想一样,其实都融入到了很多数论.图论.数据结构等具体的算法当中,那么这篇文章,我们就讨论将图论中的树结构和动态规划的结合——树形dp. 其实如果看过<背包九讲>或者看过笔者的文章<动态规划——背包问题>的读者会对树形dp有一定的了解,下面引用笔者在<动态规划——背包问题>中一个一段. “ 依赖背包问题的模型很简单,就是说对于某个物体,将它装入背包必须以装入一个物体做前提.这其实十分类似我们上文提到的分组背包…
There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tree rooted at the rector V. E. Tretyakov. In order…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1520 思路:树形DP的入门题 定义dp[root][1]表示以root为根节点的子树,且root本身参加party的最优值,那么dp[root][1]+=Σdp[son][0]+happy[root]; dp[root][0]表示以root为跟节点且root本身没有参加的最优值,那么dp[root][0]+=max(dp[son][0],dp[son][1]); 如果不理解,可以参考我对hdu105…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1520 一个公司去参加宴会,要求去的人不能有直接领导关系,给出每一个人的欢乐值,和L K代表K是L的直接领导,问最大的欢乐值是多少. 将公司的关系建为一棵树,从最大的老板向下dfs dp[i][0] 代表以编号为i的那个员工为根的一棵子树(不包含i)的最大欢乐值. dp[i][1] 代表以编号为i的那个员工为根的一棵子树(包含i)的最大欢乐值. 那么得到状态转移方程假设j为i的下属 dp[i][0] =…
Anniversary party Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6635   Accepted: 3827 Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure…
Anniversary party Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7230   Accepted: 4162 Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure…
Anniversary party Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6926   Accepted: 3985 Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure…