#P4221. [WC2018] 州区划分
[WC2018] 州区划分
Description
Xiao S currently has cities. The population of the -th city is , and there may be bidirectional roads between cities.
Now Xiao S will partition these cities into several states. Each state contains at least one city, and each city belongs to exactly one state.
Suppose Xiao S partitions the cities into states. Let be the set of all cities contained in the -th state. A road is defined to be an internal road of a state if and only if both of its endpoint cities are within that state. A state is called illegal if and only if there exists a path within this state that starts and ends at the same city, does not pass through any city outside this state, traverses every internal road of this state exactly once, and visits every city of this state at least once (the path length may be ).
Define the satisfaction of the -th state as the -th power of the proportion of the -th state's population in the total population of the first states, that is:
$$\left(\dfrac{\sum _ {x \in V _ i} w _ x}{\sum _ {j = 1} ^ i \sum _ {x \in V _ j} w _ x}\right) ^ p$$Define the satisfaction of a partition as the product of the satisfactions of all states.
Compute the sum of the satisfactions of all legal partitions.
Take the answer modulo . Two partitions and are different if and only if , or there exists some such that .
Input Format
The first line contains three integers , denoting the number of cities, the number of roads between cities, and the constant in the statement.
The next lines each contain two positive integers , describing an undirected road. There are no multiple edges and no self-loops.
Line contains positive integers, where the -th integer is .
Output Format
Output a single integer, which is the value of the answer modulo .
That is, let the answer in lowest terms be , where and are coprime. Output an integer such that and . It can be proven that such an integer is unique.
3 2 1
1 2
2 3
1 1 1
1
Hint
, where is a prime and .
Constraints (guaranteed for all testdata): , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号