依赖关系形成一棵树,要选子节点必先选择其父节点关键:把背包放在树上来做,也就是树上的01背包View Code #include<stdio.h>#include<string.h>#include<vector>using namespace std;struct node{ int v,next;}edge[10010];int head[110];int dp[110][110];int n,m,tot;void add(int s,int t){ edge[tot].v=t; edge[tot].next=head[s]; head[s]=tot++ Read More