Minimum Spanning Trees
Time limit4sMemory limit512 MB
Given a random graph where each edge has weight 0 to k or is absent, find for each s the probability that the graph is connected with MST weight s, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Probability, Combinatorics, Graph
- Solved
- No attempts yet
Problem
One day, Subconscious faced a problem that reminded him of a horrible experience in a past contest. In that contest, the easiest problem asked for the number of minimum spanning trees in a randomly generated graph.
Now there is a graph with vertices labeled from 1 to . For each pair of vertices and (), there is no edge between them with probability , or an edge of weight 1 with probability , or an edge of weight 2 with probability , and so on, up to an edge of weight with probability , where is the maximum weight of an edge. All edges are generated independently.
The task is not to find the expected weight of the minimum spanning tree, since the graph may be disconnected and the task author does not know how to deal with such cases. Instead, for each integer between and , calculate the probability that the graph is connected and the weight of its minimum spanning tree is exactly .
Subconscious thinks he has solved the problem, but he is not sure his solution is correct. He wants to check the answers modulo 1,000,000,007 with you.
Input
The input contains several test cases. The first line contains a single integer (), the number of test cases.
Each test case starts with two integers () and (), the number of vertices and the maximum edge weight. The next line contains non-negative integers with .
At most 20 test cases have , and at most 2 test cases have .
Output
For each test case, print one line with integers. The -th integer is the probability that the graph is connected and its minimum spanning tree has weight exactly , reported modulo 1,000,000,007.
More precisely, if the reduced fraction of the probability is , print the minimum non-negative integer such that . You may assume such always exists in all test cases.