https://www.luogu.org/problem/show?pid=2014
我一开始想不出来,看了题解后却发现是最基本的模型
唉~
这里因为是森林所以我们简单的把森林合并到一个节点0;
f[i][j]表示再i点的子孙里取j个的解;
当然不包括i;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#define Ll long long
using namespace std;
struct cs{
int to,next,vv;
}a[3001];