http://acm.hdu.edu.cn/showproblem.php?pid=1561
树形dp:
1 #include2 #include 3 #include 4 using namespace std; 5 6 const int mx=222; 7 int dp[mx][mx]; 8 vector g[mx]; 9 10 void dfs(int x,int m)11 {12 if (m==0) return ;13 for (int i=0;i =1;j--)18 {19 int v=j;20 for(int k=1;k >n>>m)32 {33 memset(dp,0,sizeof(dp));34 if (!n&&!m) return 0;35 int a,i;36 for (i=0;i<=n;i++) g[i].clear();37 for (i=1;i<=n;i++)38 {39 cin>>a>>dp[i][1];40 g[a].push_back(i);41 }42 dfs(0,m+1);43 cout< <