#P4365. [九省联考 2018] 秘密袭击 coat
[九省联考 2018] 秘密袭击 coat
Description
Access Globe is playing a strategy game. In the game, he controls a soldier from country C. His mission is to follow the commander’s orders to join battles and win.
Country C is about to launch a secret raid on country D. The battle plan is: choose cities in country D, and send the top-performing soldiers of country C to secretly infiltrate these cities, one soldier per city. Each city has a danger level .
The commander of country C will send the best-performing soldier to the most dangerous city among the chosen cities, the second-best to the second most dangerous city, and so on (that is, the soldier with the -th highest record goes to the city with the -th highest danger level among the chosen cities). Country D has cities, with bidirectional roads connecting them, so that every pair of cities is mutually reachable. To ensure smooth execution, among the chosen cities, any two chosen cities can reach each other without passing through any unchosen city.
Access Globe controls the soldier with the -th highest record, and he wants to estimate the danger level of the city he will eventually infiltrate. He assumes country C chooses any set of cities that satisfies the conditions uniformly at random. He wants you to compute, over all possible city sets, the sum of the danger levels of the city that Access Globe’s soldier will infiltrate. If fewer than cities are chosen, Access Globe will not be dispatched; in this case the danger level is .
Of course, you do not want to solve this problem for him, and you are not going to tell him the remainder modulo . You will only tell him the remainder modulo .
Input Format
The first line contains integers , denoting the number of cities in country D, the rank of the city that Access Globe’s soldier will infiltrate, and the maximum danger level among all cities in country D.
The second line contains integers between and , , denoting the danger level of each city.
Lines through each contain two integers , indicating that there is a bidirectional road between cities and in country D.
Output Format
Output a single integer: the remainder modulo of the sum, over all feasible city sets, of the danger level of the city that Access Globe’s soldier will infiltrate.
5 3 3
2 1 1 2 3
1 2
2 3
1 4
1 5
11
10 2 3
2 1 1 3 1 2 3 3 1 3
1 2
2 3
2 4
2 5
2 6
5 7
1 8
8 9
1 10
435
Hint
Country D’s map is shown below. A city with danger level is drawn as a -gon.

All valid choices with at least selected cities are:
- Choose cities ; the danger level for Access Globe’s soldier is .
- Choose cities ; the danger level is .
- Choose cities ; the danger level is .
- Choose cities ; the danger level is .
- Choose cities ; the danger level is .
- Choose cities ; the danger level is .
- Choose cities ; the danger level is .
- Choose cities ; the danger level is .
- When fewer than cities are chosen, the danger level is .
Therefore you should output .

Translated by ChatGPT 5
京公网安备 11011102002149号