树形DP URAL 1039 Anniversary Party】的更多相关文章

题目传送门 /* 题意:上司在,员工不在,反之不一定.每一个人有一个权值,问权值和最大多少. 树形DP:把上司和员工的关系看成根节点和子节点的关系,两者有状态转移方程: dp[rt][0] += max (dp[son][1], dp[son][0]); //上司不去 dp[rt][1] += dp[son][0]; //上司去,员工都不去 */ #include <cstdio> #include <cstring> #include <algorithm> #inc…
POJ 2342 Anniversary party / HDU 1520 Anniversary party / URAL 1039 Anniversary party(树型动态规划) 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 of emp…
题目链接:https://cn.vjudge.net/contest/277955#problem/A 题目大意:略 具体思路:刚开始接触树形dp,说一下我对这个题的初步理解吧,首先,我们从根节点开始,往下dfs,dp[i][0]代表我当前的i点不要去舞会,那么对于他的孩子节点,我们是肯定不能去舞会的,所以dp[i][0]=dp[i][0]+max(dp[son][0],dp[son][1])(注意一个上司可能有多个下属,所以需要累加),这个的具体意思是如果当前的父亲节点不去的话,我们可以选择他…
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1039 Dynamic Programming. 建立树形结构,每个employee有两个选择,去或者不去.supervisor的选择影响着sub-tree的选择.代码如下: #include <iostream> #include <math.h> #include <stdio.h> #include <cstdio> #include <…
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…
Anniversary party Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12770    Accepted Submission(s): 5142 Problem Description There is going to be a party to celebrate the 80-th Anniversary of the…
题目链接:http://poj.org/problem?id=2342 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 of employees. It means that the supervisor relation forms a tree…
Anniversary party Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3623    Accepted Submission(s): 1684 Problem Description There is going to be a party to celebrate the 80-th Anniversary of the…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1520 Anniversary party Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16376    Accepted Submission(s): 6241 Problem Description There is going to…
http://acm.timus.ru/problem.aspx?space=1&num=1039 1039. Anniversary Party Time limit: 0.5 secondMemory limit: 8 MB Background The president of the Ural State University is going to make an 80'th Anniversary party. The university has a hierarchical st…