luogu#P5575. [CmdOI2019] 黑白图

[CmdOI2019] 黑白图

Background

You saw a strange graph.

Problem Description

There is a simple undirected connected graph with nn vertices and mm edges. Each vertex can be colored black or white.

This graph is relatively sparse. Specifically, there are two cases.

  • m=n1m=n-1, in which case it is a tree.

  • m=nm=n, in which case it is a unicyclic graph (a tree with one extra edge).

We define the value of a black-and-white graph as follows: the sum of the kk-th powers of the sizes of its black connected components.

Now the shape of the graph is fixed, but the color of each vertex is not fixed. For the ii-th vertex, it has a probability of pip_i percent to be black; otherwise it is white.

Compute the expected value of the graph, modulo 998244353998244353.

Input Format

The first line contains three positive integers n,m,kn,m,k, with meanings as described above.

The next line contains nn numbers, which are p1np_{1\sim n} in order.

The next mm lines each contain two numbers f,tf,t, indicating an undirected edge ftf\leftrightarrow t in the graph.

Output Format

Output one integer, the expected value of the graph modulo 998244353998244353.

5 4 3
50 50 50 50 50
1 2
2 3
2 4
2 5
19
6 5 2
20 30 40 50 60 70
1 2
2 3
2 4
2 5
4 6
397301258
10 10 2
39 76 71 86 36 38 36 44 63 37 
4 5
2 10
6 10
1 8
5 10
8 10
7 10
3 10
10 9
5 3
361859252

Hint

Test Point ID nn mm kk Property 1 Property 2 Score
1 1616 n1n-1 55 \sqrt{} - 55
2 5050 33 \sqrt{}
3 55 -
4 500500 11 -
5 2×1052\times 10^5 33 \sqrt{} \sqrt{}
6 22 -
7 44 - 1010
8 1616 nn 33
9 500500
10 5000050000 22
11 2×1052\times 10^5 44 \sqrt{}
12 55 -
13

Special Property 11: pi=50p_i=50.

Special Property 22: The graph degenerates into a single chain, where there is an edge between ii and i+1i+1.

Translated by ChatGPT 5