
树形dp
codediyi
你可以关注我的知乎主页,去看我分享的更多内容。
https://www.zhihu.com/people/codediyi
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Hdu2196(树形dp,只有代码)
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int num=6*1e3+10;struct node{ int v,next;}e[num];int head[num],p[num],cnt;int a[num];int d...原创 2019-09-20 17:07:08 · 115 阅读 · 0 评论 -
HDU2196_Computer_求树上的每一个点可以达到的最大距离
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int num=1e4+10;struct node{ int v,next,w;}e[2*num];int head[2*num],cnt;int dp[num][2];void...原创 2019-09-20 18:59:40 · 186 阅读 · 0 评论 -
Tree Cutting POJ - 2378+Poj3107+求树的重心
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int inf=1e8;const int num=1e4+10;struct node{ int v,next;}e[2*num];int head[2*num],cnt;int...原创 2019-09-20 20:14:24 · 149 阅读 · 0 评论 -
Poj3140求树重心
//编译错了两次,原因:abs(a),a不能是LL类型#include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef long long LL;const LL inf=1e17;const int num_e=2*1e6+10;struct nod...原创 2019-09-20 21:15:43 · 112 阅读 · 0 评论 -
树形dp+01背包例题
树形dp+01背包#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int num=210;struct node{ int v,next;}e[num];struct point{ int p,w;}a[num];i...原创 2019-10-08 20:13:33 · 192 阅读 · 0 评论 -
HDU2422_考研路茫茫——空调教室_Tarjan缩点+树形dp/判断联通块数量
考研路茫茫——空调教室的题目链接题目数据:N和M(0<N<=10000,0<M<20000)一开始以为是树的重心,结果一直提示超内存,后来看了看题,发现不对,m>n-1啊,不可能是树;肯定有环;但是我们破坏环中的任意一条边,都不会满足题意。所以我们寻找的那条边肯定不在环里,而分开之后,在一个环里的那些点不会分开,所以可以见一个环变成一个点;这样就可以把...原创 2019-10-10 18:12:35 · 187 阅读 · 0 评论 -
受欢迎的牛+Trajan缩点+树形dp
题目链接:题目解析:题目数据:100%的数据N<=10000,M<=50000;显然这个图里面会有环,而我们可以做的是:判断这个点是否是其它点的子节点;因此:要把这个图转化为树;用到Trajan算法;在这道题中:可能会出现如下情况:a-->b<--c; | | V(箭头) d 就是有a ,c这两个入度为0的点; 所以要用一个...原创 2019-10-11 09:42:11 · 178 阅读 · 0 评论