Master of Subgraph

TimeLimit:0MS  MemoryLimit:0MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

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题

Input

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.

Output

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.

SampleInput
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

SampleOutput
0110101010
1011111010
Submit
题目统计信息详细
总AC数2
通过人数2
尝试人数2
总提交量2
AC率100.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: