码迷,mamicode.com
首页 >  
搜索关键字:树形dp    ( 1929个结果
Codeforces 462D Appleman and Tree 树形dp
题目链接:点击打开链接 #include #include #include #include #include using namespace std; #define N 300100 #define mod 1000000007 typedef long long ll; ll dp[N][2]; //dp[i][1]表示i点已经归属于某个黑点的方法数 //dp[i][...
分类:移动开发   时间:2014-08-30 23:11:50    阅读次数:438
Codeforces 461 B. Appleman and Tree
树形DP。。。 B. Appleman and Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Appleman has a ...
分类:移动开发   时间:2014-08-30 15:11:29    阅读次数:246
Codeforces Round #263 (Div. 1) A B C
Codeforces Round #263 (Div. 1) A:贪心,排个序,然后从后往前扫一遍,计算后缀和,之后在从左往右扫一遍计算答案 B:树形DP,0表示没有1,1表示有1,0遇到0必然合并,0遇到1也必然合并,1遇到0必然合并,1遇到1,必然切断,按照这样去转移即可 C:树状数组,再利用启发式合并,开一个l,r记录当前被子左右下标,和一个flip表示是否翻转 代码...
分类:其他好文   时间:2014-08-30 12:38:09    阅读次数:281
hdu 4276 The Ghost Blows Light(DP-树形DP)
hdu 4276 The Ghost Blows Light(DP-树形DP)...
分类:其他好文   时间:2014-08-29 21:26:18    阅读次数:370
ZOJ-3626 Treasure Hunt I 树形DP
很久很久以前有一个吸血鬼,每m天就会出现一次,把不在自己村子呆着的冒险家吃掉。有n个村子,n-1条道路,每个村子都有一定数量的财富,默认探险家刚一到达一个村子就能获得财富,给出探险家的出生的村子和多少天后吸血鬼出现。 要求在吸血鬼出现之前赶回自己的村子,其实就是求一棵以k为根的各点权值之和最大且各边权加起来 #include #include #include #include #in...
分类:其他好文   时间:2014-08-29 16:07:48    阅读次数:214
poj3342Party at Hali-Bula(树形dp)
1 /* 2 树形dp! 3 判重思路: 4 当dp[v][0]==dp[v][1]时,很自然,flag[u][0]必然是有两种方案的。flag[u][1]则不然, 5 因为它只和dp[v][0]有关系。而若flag[v][0]不唯一时,则必然flag[u][1]也不唯一 ...
分类:其他好文   时间:2014-08-29 14:24:18    阅读次数:154
hdu1561--H - ACboy needs your help(树形dp)
H - ACboy needs your help Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status   Description ACboy has N courses this term, and he plans to spend...
分类:其他好文   时间:2014-08-27 22:02:48    阅读次数:246
Codeforces Round #263 (Div. 1)
B 树形dp组合的思想。Z队长的思路。dp[i][1]表示以i为跟结点的子树向上贡献1个的方案,dp[i][0]表示以i为跟结点的子树向上贡献0个的方案.如果当前为叶子节点,dp[i][0] = 1,(颜色为1,可以断开与父节点的连接,颜色为0,不断开,方案恒为1),dp[i][1] = co[i]...
分类:其他好文   时间:2014-08-27 18:35:58    阅读次数:270
Codeforces Round #263 (Div. 2) D. Appleman and Tree(树形DP)
题目链接D. Appleman and Treetime limit per test :2 secondsmemory limit per test:256 megabytesinput :standard inputoutput:standard outputAppleman has a tre...
分类:移动开发   时间:2014-08-27 18:18:48    阅读次数:270
14D-树形DP
找出树中2条不重复的路径使其路径长度乘积最大#include #include #include #include #include using namespace std;const int MAXN = 205;typedef pair Edge;vector adj[MAXN];bool de...
分类:其他好文   时间:2014-08-26 13:32:16    阅读次数:197
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!