2022 International Collegiate Programming Contest, Jinan Site C. DFS Order 2(树形dp+回滚背包)
题目n(n=1;--i){for(intj=sz[u];j>=sz[v];--j){f[i][j]+=f[i-1][j-sz[v]];}}}算g数组和dp数组之前,把v撤销掉,算完后反撤销,也就是再加回来,再dfs子树复杂度代码#include//#includeusingnamespacestd;#definerep(i,a,b)for(inti=(a);i=(b);--i)typedeflon