Fake Plastic Trees 2

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

You are given a tree with NN vertices. Vertices are indexed from 11 to NN. The tree is vertex-weighted. In other words, each vertex of the tree is assigned a nonnegative integer weight.

We will delete some edges from the tree. After the deletion, for each connected component, the sum of vertex weights should be in the range \[L,R]\[L, R]

For all integers 0iK0 \le i \le K, determine if we can achieve this goal by deleting exactly ii edges.

입력

The first line contains a single integer TT, the number of test cases. TT test cases follow, each following the given specification:

The first line contains four integers NN, KK, LL, and RR.

The next line contains NN integers A_1,A_2,,A_NA\_1, A\_2, \ldots, A\_N, where A_iA\_i denotes the weight of vertex ii.

The next N1N-1 lines contain two integers x,yx, y, denoting the pair of vertices connected by an edge.

출력

For each test case, output a binary string of length K+1K + 1. The ii-th character should be 1 if it is possible to achieve the desired goal by deleting exactly i1i-1 edges. Otherwise, the ii-th character should be 0.

제한

  • 1N1,0001 \le N \le 1\\,000
  • 0Kmin(50,N1)0 \le K \le \min(50, N - 1)
  • 0LR10180 \le L \le R \le 10^{18}
  • 0A_i10180 \le A\_i \le 10^{18}
  • 1x,yN1 \le x, y \le N
  • xyx \neq y
  • The given graph is a tree.
  • For all test cases, the sum of NN is at most 1,0001\\,000.