被坑。。。hdu都是多组数据读入的----------------------------------------------------------------------------------------------#include#include#include#include#includ...
分类:
其他好文 时间:
2015-12-15 21:08:20
阅读次数:
261
Anniversary party
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7303 Accepted Submission(s): 3220
Problem Description
There is going to ...
分类:
其他好文 时间:
2015-11-07 16:12:29
阅读次数:
240
题意:给出了,参加party的人的关系,但是如果一个人的直接上司出席,那么他就不会出席,每个人有自己的rating。现在想要rating最大。在网上找了半天,也没找到比较好的树形DP讲解,暂时的感觉是利用DFS搜索的时候,回溯更新。
1.dp[u][0]:表示u这个人不去,那么他的手下v可以选择去或者不去。所以 dp[u][0]+=max(dp[v][0],dp[v][1]);
2.dp[i][...
分类:
其他好文 时间:
2015-08-29 17:02:10
阅读次数:
132
题目链接:点击打开链接
题目描述:现有一棵树,树上每个结点都有一个权值,问从中选一些点,这些点两两之间不直接连接,问权值最大为多少?
解题思路:很裸的一道树上最大独立集问题 树形dp即可
dp[i][0]:不选i节点 dp[i][0]+=max(dp[t][0],dp[t][1]);
dp[i][1]:选i节点 dp[i][1]+=dp[t][0];
代码:
#pragma c...
分类:
其他好文 时间:
2015-08-26 12:09:25
阅读次数:
147
【树形dp】就是在树上做的一些dpdp之类的递推,因为一般需要递归处理,因此平凡情况的处理可能需要理清思路。昨晚开始切了44题,作为入门训练。题目都非常简单,但是似乎做起来都还口以~
hdu1520hdu1520
给一颗关系树,各点有权值,选一些点出来。任一对直接相连的边连接的点不能同时选择,问选择出的权值和最大为多少。
考虑以uu为根的子树可以选择的方法,dp[u]dp[u]表示选择uu时能获得最...
分类:
其他好文 时间:
2015-08-19 20:40:33
阅读次数:
166
Problem DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical str...
分类:
其他好文 时间:
2015-05-21 23:57:35
阅读次数:
308
每个节点有权值,子节点和父节点不能同时选,问最后能选的最大价值是多少?
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long int64;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);...
分类:
其他好文 时间:
2015-05-01 14:50:24
阅读次数:
124
hdu1520http://acm.hdu.edu.cn/showproblem.php?pid=1520题意是给定一棵树,每个结点有一个价值,要我们选择任意个结点使得总价值最大,规则是如果父亲结点被选了,那么儿子结点不可以被选,但是儿子的儿子可以被选本来学搜索的时候找到这题搜索题,然后用搜索做的 ...
分类:
其他好文 时间:
2015-04-19 14:40:27
阅读次数:
120
基本的树形dp#include #include #include using namespace std;const int MAX_N = (int)(6e3) + 5;int n;int weight[MAX_N];vector edge[MAX_N];bool vis[MAX_N];int....
分类:
其他好文 时间:
2015-03-31 20:01:55
阅读次数:
127
http://acm.hdu.edu.cn/showproblem.php?pid=1520
Problem Description
There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierar...
分类:
其他好文 时间:
2015-02-08 10:24:25
阅读次数:
144