luogu#P5575. [CmdOI2019] 黑白图
[CmdOI2019] 黑白图
Background
You saw a strange graph.
Problem Description
There is a simple undirected connected graph with vertices and edges. Each vertex can be colored black or white.
This graph is relatively sparse. Specifically, there are two cases.
-
, in which case it is a tree.
-
, 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 -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 -th vertex, it has a probability of percent to be black; otherwise it is white.
Compute the expected value of the graph, modulo .
Input Format
The first line contains three positive integers , with meanings as described above.
The next line contains numbers, which are in order.
The next lines each contain two numbers , indicating an undirected edge in the graph.
Output Format
Output one integer, the expected value of the graph modulo .
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 | Property 1 | Property 2 | Score | |||
|---|---|---|---|---|---|---|
| 1 | - | |||||
| 2 | ||||||
| 3 | - | |||||
| 4 | - | |||||
| 5 | ||||||
| 6 | - | |||||
| 7 | - | |||||
| 8 | ||||||
| 9 | ||||||
| 10 | ||||||
| 11 | ||||||
| 12 | - | |||||
| 13 |
Special Property : .
Special Property : The graph degenerates into a single chain, where there is an edge between and .
Translated by ChatGPT 5