#P9248. [集训队互测 2018] 完美的集合

    ID: 10063 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学递推2018集训队互测多项式O2优化背包 DP

[集训队互测 2018] 完美的集合

Problem Description

Little A has a weighted tree with NN nodes. Each node has a weight wiw_i and a value viv_i.

Now Little A wants to select some nodes to form a set SS, such that the total weight of these nodes is M\leq M and they form a connected component. Little A is a perfectionist, so he will only choose those SS with the maximum possible total value among all sets that satisfy the conditions. We call such a set SS a perfect set.

Now Little A wants to choose KK sets from all perfect sets, and test these KK perfect sets separately. Before these KK tests begin, Little A first needs a node xx to place his testing device, whose maximum power is MaxMax.

In each subsequent test, Little A will transmit energy once to all nodes in the test object SS. The power required to transmit energy to a node yy is dist(x,y)×vydist(x,y)\times v_y, where dist(x,y)dist(x,y) denotes the length of the shortest path between nodes xx and yy on the tree. Therefore, if there exists a node yy in SS such that dist(x,y)×vy>Maxdist(x,y)\times v_y>Max, the test will fail. At the same time, in order to ensure stable energy transmission, the node xx where the device is placed must be in the set SS, otherwise the test will also fail.

Now Little A wants to know: how many ways are there to choose KK sets from all perfect sets, such that he can find a node to place the testing device and complete his tests?

You only need to output the number of ways modulo 1192092895507812511920928955078125.

Input Format

The first line contains four positive integers, denoting N,M,K,MaxN,M,K,Max.

The next line contains NN positive integers, denoting w1,,wNw_1,\dots,w_N.

The next line contains NN non-negative integers, denoting v1,,vNv_1,\dots,v_N.

The next N1N-1 lines each contain three positive integers Ai,Bi,CiA_i,B_i,C_i, meaning there is an edge of length CiC_i connecting nodes Ai,BiA_i,B_i in the tree.

Output Format

One number, denoting the number of ways modulo 1192092895507812511920928955078125.

7 3 2 4
1 1 2 2 1 2 2
1 1 1 2 1 2 2
1 2 1
1 3 2
1 4 2
2 5 1
2 6 2
4 7 3
2

Hint

Sample Explanation

The perfect sets are {1,2,5},{1,4},{2,6}\{1,2,5\},\{1,4\},\{2,6\}.

The ways to choose KK sets from them and still complete the tests are: choosing {1,2,5},{1,4}\{1,2,5\},\{1,4\}, or choosing {1,2,5},{2,6}\{1,2,5\},\{2,6\}.

Constraints

Subtask ID NN\leq MM\leq KK\leq Special Property Score
11 1717 150150 10910^9 1313
22 6060 1000010000 11 1111
33 22 10410^4 w1==wN=1w_1=\dots=w_N=1 1919
44 4040 12001200 10910^9 2020
55 6060 1000010000 10410^4 1515
66 10910^9 2222

For 100%100\% of the testdata: N60N\leq 60, M10000M\leq 10000, Ci10000C_i\leq 10000, K,wi,vi109K,w_i,v_i\leq 10^9, and Max1018Max\leq 10^{18}.

Translated by ChatGPT 5