You are given a tree with n nodes. The weight of the i-th node is wi. Given a positive integer m,
now you need to judge that for every integer i in [1,,m] whether there exists a connected subgraph
which the sum of the weights of all nodes is equal to i
比赛题目:
http://acm.hdu.edu.cn/downloads/CCPC2018-Hangzhou-ProblemSet.pdf
E题
The frst line contains an integer T (1 ≤ T ≤ 15) representing the number of test cases.
For each test case, the frst line contains two integers n (1 ≤ n ≤ 3000) and m (1 ≤ m ≤ 100000),
which are mentioned above.
The following n - 1 lines each contains two integers ui and vi (1 ≤ ui,vi ≤ n). It describes an edge
between node ui and node vi.
The following n lines each contains an integer wi (0 ≤ wi ≤ 100000) represents the weight of the i-th
node.
It is guaranteed that the input graph is a tree.
For each test case, print a string only contains 0 and 1, and the length of the string is equal to m. If
there is a connected subgraph which the sum of the weights of its nodes is equal to i, the i-th letter
of string is 1 otherwise 0.
2 4 10 1 2 2 3 3 4 3 2 7 5 6 10 1 2 1 3 2 5 3 4 3 6 1 3 5 7 9 11
0110101010 1011111010