题目:http://www.51nod.com/Challenge/Problem.html#!#problemId=1673 建一个虚树. 一种贪心的想法是把较小的值填到叶子上,这样一个小值限制到的叶子比较少. 但不太会贪心了,所以考虑 DP .只有 20 个叶子,(不是用来暴搜的!)可以状压DP了. dp[ S ]表示选了点集 S 的叶子的方案数.再记一个 ct[ S ] 表示选这个点集的叶子.不影响到其他叶子,最多可以填几个点. dp[ S ]可以枚举最后一个填的是哪个叶子来转移:ct[…
Flowers Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3148 Accepted Submission(s): 1549 Problem Description As is known to all, the blooming time and duration varies between different kinds…
Description You are given a tree with N nodes. The tree’s nodes are numbered 1 through N and its edges are numbered 1 through N − 1. Each edge is associated with a weight. Then you are to execute a series of instructions on the tree. The instructions…