#P4221. [WC2018] 州区划分

    ID: 3152 远端评测题 10000~15000ms 1000MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp数学2018WC/CTSC/集训队状态压缩,状压欧拉回路快速傅里叶变换 FFT

[WC2018] 州区划分

Description

Xiao S currently has nn cities. The population of the ii-th city is wiw_i, and there may be bidirectional roads between cities.

Now Xiao S will partition these nn 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 kk states. Let ViV_i be the set of all cities contained in the ii-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 00).

Define the satisfaction of the ii-th state as the pp-th power of the proportion of the ii-th state's population in the total population of the first ii 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 998244353998244353. Two partitions {V1,V2,,Vk}\{V_1, V _ 2, \cdots, V_k\} and {C1,C2,,Cs}\{C_1, C _ 2, \cdots, C_s\} are different if and only if ksk \neq s, or there exists some 1ik1 \leq i \leq k such that ViCiV_i \neq C_i.

Input Format

The first line contains three integers n,m,pn, m, p, denoting the number of cities, the number of roads between cities, and the constant pp in the statement.

The next mm lines each contain two positive integers u,vu, v, describing an undirected road. There are no multiple edges and no self-loops.

Line m+2m+2 contains nn positive integers, where the ii-th integer is wiw_i.

Output Format

Output a single integer, which is the value of the answer modulo 998244353998244353.

That is, let the answer in lowest terms be a/ba/b, where aa and bb are coprime. Output an integer xx such that bxa(mod998244353)b x \equiv a \pmod{ 998244353} and 0x<9982443530 \leq x < 998244353. It can be proven that such an integer xx is unique.

3 2 1
1 2
2 3
1 1 1
1

Hint

[Hint][ \text{Hint} ]

xp11(modp)x^{p-1} \equiv 1 \pmod p, where pp is a prime and x[1,p)x \in [1, p).

Constraints (guaranteed for all testdata): 0n210 \leq n \leq 21, 0mn×(n1)20 \leq m \leq \dfrac{n \times (n-1)}{2}, 0p20 \leq p \leq 2, 1wi1001 \leq w_i \leq 100.

Translated by ChatGPT 5