Anniversary party
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 4410
Accepted: 2496
Description
There is going to be a party to celebrate the 80-th Ann...
分类:
其他好文 时间:
2014-10-28 12:14:05
阅读次数:
205
题意:
n个节点的树 每个节点上有个价值 要求选出k个两两互相没有祖孙关系的节点 使得价值和最大
思路:
明显的树形dp 如果用dp[fa][i]表示fa子树取i个点的最大价值和 则有转移 dp[fa][i]=max(dp[son][k]+dp[fa][i-k])
但是如果这样开数组会MLE 所以本题猥琐的使用dfs内部开数组的方式 这样借助全局变量的帮助 我们可以避免M...
分类:
其他好文 时间:
2014-10-25 23:06:50
阅读次数:
370
题意:一棵n个结点的无根树(0
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1054
——>>状态:
dp[i][1]表示以 i 为结点的子树,在 i 放一个士兵,可以守护所有边的最少士兵数。
dp[i][0]表示以 i 为结点的子树,在 i 不放士兵,可以守护所有边的最少士兵数。
状态转移方程(结点 j 是结点 i 的儿子):
dp...
分类:
其他好文 时间:
2014-10-25 20:10:37
阅读次数:
281
Problem Description
Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. H...
分类:
其他好文 时间:
2014-10-25 18:51:18
阅读次数:
204
Problem Description
A school bought the first computer some time ago(so this computer's id is 1). During the recent years the school bought N-1 new computers. Each new computer was connected to one...
分类:
其他好文 时间:
2014-10-25 18:51:08
阅读次数:
133
题意:一棵n个结点的有根树(1
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2412
——>>状态:
dp[i][1]表示以结点 i 为根的子树,且选择i,能找出的满足要求的最大结点数。
dp[i][0]表示以结点 i 为根的子树,且不选择i,能找出的满足要求的最大结点数。
状态转移方程(结点 j 是结点 i 的儿子):
dp[i][...
分类:
其他好文 时间:
2014-10-25 15:57:40
阅读次数:
193
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4003题目大意:有K个机器人,走完树上的全部路径,每条路径有个消费。对于一个点,机器人可以出去再回来,开销2倍。也可以不回来,一直停在某个点(如果你的机器人数量足够多的话)。问最小开销。解题思路:其实这题...
分类:
其他好文 时间:
2014-10-24 16:05:01
阅读次数:
237
一个简单的树上的背包问题。代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12...
分类:
其他好文 时间:
2014-10-24 01:41:36
阅读次数:
174
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3626题目大意:树中取点。每过一条边有一定cost,且最后要回到起点。给定预算m,问最大价值。解题思路:首先要注意这题要回到起点,由于树的特殊结构(每个结点只有一个父...
分类:
其他好文 时间:
2014-10-22 09:54:13
阅读次数:
171
题解:点击打开链接
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const double eps = 1e-9;
const int N = 10010;
vector G[N];
int n;
double k[N], e[N], dp[N];
do...
分类:
其他好文 时间:
2014-10-21 15:28:49
阅读次数:
141