![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树形DP
ToheartZhang
这个作者很懒,什么都没留下…
展开
-
例题 9-14 完美的服务 UVa 1218
#include<bits/stdc++.h>using namespace std;const int inf = 10010;int n;int dp[inf][3];int vis[inf];vector<int> son[inf];void go(int rt){ vis[rt] = 1; dp[rt][0] = 1; dp[rt][1] = 0;原创 2017-04-30 20:49:17 · 343 阅读 · 0 评论 -
CODEVS 1163 访问艺术馆
#include<bits/stdc++.h>using namespace std;int t, num, ans;int dp[201][601];//第i个点可花j秒收集多少幅画。 int dfs(int rt){ int ti, sum; cin >> ti >> sum; ti *= 2; int son = ++num; if(!sum){原创 2017-04-15 22:34:02 · 208 阅读 · 0 评论 -
SDSC 2017 Day5 T2
//f[i]表示以i为根子树归零累加值,g{i]表示累减值//肯定是先搞定底部再搞上面 #include<bits/stdc++.h>using namespace std;const int maxn = 300010;int n, a[maxn], st[maxn], tot = 0;long long f[maxn], g[maxn];struct node{ int v,原创 2017-08-25 11:28:51 · 315 阅读 · 0 评论 -
洛谷 2014 选课
//dp[i][j]是以i为根不算i的子树选j门课的学分 #include<bits/stdc++.h>using namespace std;const int maxn = 3030;int n, m, tot = 0;int dp[maxn][maxn], st[maxn], a[maxn];struct node{ int v, w, nxt;} edge[maxn];原创 2017-08-28 17:49:03 · 480 阅读 · 0 评论 -
暑末 Day2 T3
//maxd表示根到叶子的最大距离//预处理maxd,即知需修改的长度 //to != fa #include<bits/stdc++.h>using namespace std;const int maxn = 500000;////const int inf = 0x3f3f3f3f;int n, tot, ans;int st[maxn], out[maxn], dep[max原创 2017-08-29 17:28:24 · 307 阅读 · 0 评论