![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树形dp
吴俊达9812
这个作者很懒,什么都没留下…
展开
-
bzoj 4015: [FJOI2014]树的重心 dp
主子树dp#include <bits/stdc++.h>using namespace std;typedef long long LL;const int maxn = 205;const int maxm = 505;const LL mod = 10007;int tot,he[maxn],ne[maxm],ver[maxm];void add( in...原创 2019-11-06 23:50:15 · 139 阅读 · 0 评论 -
hdu6540 Neko and tree
这是一道经典的树形dp,方法是分主子树进行dp。坑点:主树的dp值会实时修改,所以不能用dp[ x ][ i ],只能用 temp1[ i ] - temp1[ i-1 ]#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const lint maxn=...原创 2019-07-01 13:25:11 · 311 阅读 · 0 评论 -
hdu 6662 ( Acesrc and Travel )
这题我的收获有两个,一个是无向图的树形dp,本质上是有根树的dp加上父边反向的dp。另一个是这题边界条件比较多,如果用特判的话比较难写,应该 给每一个数组赋初始值,免去了特判的过程。#include <bits/stdc++.h>using namespace std;typedef long long LL;typedef int lint;const int maxn...原创 2019-08-15 10:51:01 · 449 阅读 · 0 评论