#P8352. [SDOI/SXOI2022] 小 N 的独立集

    ID: 9433 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>各省省选2022山东O2优化山西DP 套 DP

[SDOI/SXOI2022] 小 N 的独立集

Problem Description

Little N likes the maximum weight independent set problem.

One day, he received a series of tasks for creating problems, so he conveniently created a series of maximum weight independent set problems.

To generate testdata for this whole series at the same time, Little N generated a tree with nn vertices and chose a positive integer kk. Then, every time he generates one test case, he only needs to randomly generate an integer vertex weight between 1k1 \sim k for each vertex, and he can obtain a new maximum independent set problem.

Little N gave these problems to his good friend, Little Ω. Little Ω said that there were too many problems and they were too messy, so he planned to classify and process all knk^n problems. A natural idea is to classify them by the answer (that is, the sum of vertex weights in a maximum weight independent set). Obviously, the answers to these maximum weight independent set problems must be between 1nk1 \sim nk, so Little Ω only needs to manage all problems by splitting them into nknk categories according to the answer.

Before Little N officially starts creating problems, Little Ω first needs to compute exactly how many problems there are in each category. After a rough estimate, Little Ω quickly realized that he did not have the kind of memory described in Shiyun, so he firmly rejected Little N’s suggestion of “generate all possible problems first and then slowly classify and count them”. Then, tragically, he realized that he could not compute these numbers either.

He wants you to help him solve this problem. He also said that if you successfully solve it, then when Little N releases those maximum weight independent set problems, he will help you submit a reference solution code.

Input Format

The first line contains 22 positive integers nn, kk.

The next n1n - 1 lines each contain 22 positive integers uiu_i, viv_i, describing an edge connecting vertices uiu_i and viv_i. It is guaranteed that these edges form a tree.

Output Format

Output nknk lines, each containing one integer. The ii-th integer indicates, among all possible problems, how many have a maximum weight independent set total weight equal to ii, modulo 109+710^9+7.

4 2
1 2
2 3
2 4
0
0
2
6
6
2
0
0

Hint

Sample Explanation

There are a total of 24=162^4 = 16 maximum weight independent set problems that satisfy the statement.

It can be proven that when the weights of vertices 11, 33, and 44 are all 11, the maximum weight independent set has total weight 33, and there are 22 such problems. When exactly one of the weights of vertices 11, 33, and 44 is 22, the maximum weight independent set has total weight 44, and there are 66 such problems. The cases where the maximum weight independent set has total weight 55 or 66 are similar.

Constraints

For 15%15\% of the testdata, n8n \leq 8;
For 30%30\% of the testdata, n30n \leq 30;
For 50%50\% of the testdata, n100n \leq 100;
For another 10%10\% of the testdata, k=1k = 1;
For another 15%15\% of the testdata, k=2k = 2;
For 100%100\% of the testdata, n1000n \leq 1000, k5k \leq 5, ui,vinu_{i}, v_{i} \leq n.

Hint

The maximum weight independent set problem means: choose a set of vertices such that no two chosen vertices are directly connected by an edge, and the sum of the chosen vertices’ weights is maximized.

Translated by ChatGPT 5