HDU 6228 tree 简单思维树dp】的更多相关文章

一.前言 前两天沈阳重现,经过队友提点,得到3题的成绩,但是看到这题下意识觉得题目错了,最后发现实际上是题目读错了....GG 感觉自己前所未有的愚蠢了....不过题目读对了也是一道思维题,但是很好理解. 二.题意 对于一个无相无环图,要求找出若干边,满足“这些边被至少K个不同的点集在互相联通的时候访问到”.或者说“这些边都包含在K个不同的点集个字组成的联通快里面”. 三.题解 考虑如何表示一个边,以及这条边两边的点的数量?(这是一棵树)作为一颗树,就有树边概念,因而可以认为“该树包括他自己在内…
[HDU 5293]Tree chain problem(树形dp+树链剖分) 题面 在一棵树中,给出若干条链和链的权值,求选取不相交的链使得权值和最大. 分析 考虑树形dp,dp[x]表示以x为子树的最大权值和(选的链都在i的子树中) 设sum[x]表示x的儿子的dp值和,即\(\sum _{y \in \mathrm{son}(x)} dp[y]\) 1.不选两端点lca为x的链,dp[x]=sum[x] 2.选两端点lca为x的链,则dp[x]=max{链的权值+链上节点的所有子节点dp的…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5293 题意: 给你一些链,每条链都有自己的价值,求不相交不重合的链能够组成的最大价值. 题解: 树形dp, 对于每条链u,v,w,我们只在lca(u,v)的顶点上处理它 让dp[i]表示以i为根的指数的最大值,sum[i]表示dp[vi]的和(vi为i的儿子们) 则i点有两种决策,一种是不选以i为lca的链,则dp[i]=sum[i]. 另一种是选一条以i为lca的链,那么有转移方程:dp[i]=…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6228 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Problem DescriptionConsider a un-rooted tree T which is not the biological significance of tree or plant, but a tre…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6058    Accepted Submission(s): 2743 Problem Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State Univers…
这里有三道长得像的题: 一:HDU6036: There is a tree with nn nodes, each of which has a type of color represented by an integer, where the color of node ii is cici. The path between each two different nodes is unique, of which we define the value as the number of…
Problem Description You are given a tree with N nodes which are numbered by integers 1..N. Each node is associated with an integer as the weight. Your task is to deal with M operations of 4 types: 1.Delete an edge (x, y) from the tree, and then add a…
题意:询问树上结点x到结点y路上上的权值异或z的最大值. 任意结点权值 ≤ 2^16,可以想到用字典树. 但是因为是询问某条路径上的字典树,将字典树可持续化,字典树上的结点保存在这条路径上的二进制数. 按照dfs序建树,结点u的字典树表示u到根结点路径上的字典树. 如果两个结点u和v,在同一条通往根结点的路径上,将会满足可减性. 因此只需要知道u.v.lca和fa[lca]四个结点的字典树就可以回答了. /*********************************************…
题意: 给出一棵\(n\)个节点的树和\(m\)条链,每条链有一个权值. 从中选出若干条链,两两不相交,并且使得权值之和最大. 分析: 题解 #include <cstdio> #include <cstring> #include <algorithm> #include <map> #include <set> #include <vector> #include <iostream> #include <str…
magic balls Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 323    Accepted Submission(s): 90 Problem Description The town of W has N people. Each person takes two magic balls A and B every day.…