摘要:
先dfs球每个点的子树总结点数(包括他自己)。。然后就显然了。。# include # include # include # include # include using namespace std;int d[20000],pa[20000];typedef struct NODE{ int k;struct NODE* next;}Node;Node edge[2*20000],*G[10001],*tail = edge;void add(int a,int b){ tail->k = b;tail->next = G[a];G[a] = tail++;}int dfs( 阅读全文
摘要:
经典dp。。不多说啦。因为他是n-1条边,所以不用考虑森林的情况# include # include # include # include # include # define inf -0x7ffffffusing namespace std;typedef struct NODE{ int k;struct NODE* next;}Node;Node edge[7000],*tail=edge,*G[7000];void add(int a,int b){ tail->k = b;tail->next = G[a];G[a] = tail++;}int v[7000],vi 阅读全文
摘要:
贪心+dp# include # include # include # define inf -0x7ffffffusing namespace std;int a[2000],b[2000],d[1001][1001];int dp(int i,int j){ if (i>j) return 0; if (d[i][j]!=inf) return d[i][j]; int t = j-i+1; if (a[j]>b[t]) return d[i][j] = dp(i,j-1)+200; if (a[j]<b[t]) return d[i][j] = dp(i+... 阅读全文