传送门 题目分析 题意:给一颗无根树,选择最少的节点将所有的边覆盖. 经典的树型DP,dp[i][0/1]表示选择或不选择i号节点的最优值. 当选择了i号节点,他的子节点可选可不选,选择最优的. 当不选择i号节点,他的子节点必须被选. 最优返回dp[1][0]和dp[1][1]的较小值. code #include<bits/stdc++.h> using namespace std; const int N = 1500; int n; int ecnt, adj[N + 5], go[N…
#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; ; struct edge{ int to; int nxt; }; int n,g[maxn],dep[maxn],dpd[maxn],dpv[maxn]; int head[maxn],cnt; edge e[maxn];…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1561 The more, The Better Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7031 Accepted Submission(s): 4121 Problem Description ACboy很喜欢玩一种战略游戏,…
id=3140">[POJ 3140] Contestants Division(树型dp) Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9121 Accepted: 2623 Description In the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and stud…