Tree Dp
文章平均质量分 71
haha_2678
Do the impossible!!!
展开
-
Hdu 1520 题解
简单树形dp f[x][1]+=f[y][0]; f[x][0]+=max(f[y][0],f[y][1]); 最后加上自己的权值即可。 Code: #include #include #include using namespace std; struct node { int x,y,next; }a[1110000]; int first[110000],len; int dp原创 2015-01-13 12:51:09 · 266 阅读 · 0 评论 -
Hdu 2196 题解
用了两种做法, 一种是每一个节点做根来扫 果断O(n(n+m)) 显然不行 另一种是1做根,判断每种情况 把另外一个孩子节点的最大值和连上去的值加起来做treedp即可 时间复杂度O(n+m) Code: #include #include #include #define max(x,y) (x)>(y)?(x):(y) using namespace std; int n; str原创 2015-01-14 13:59:23 · 371 阅读 · 0 评论