#P4365. [九省联考 2018] 秘密袭击 coat

    ID: 3338 远端评测题 7000ms 1000MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划,dp2018线段树各省省选枚举,暴力背包

[九省联考 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 ss cities in country D, and send the ss top-performing soldiers of country C to secretly infiltrate these cities, one soldier per city. Each city has a danger level did_i.

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 ii-th highest record goes to the city with the ii-th highest danger level among the chosen cities). Country D has nn cities, with n1n - 1 bidirectional roads connecting them, so that every pair of cities is mutually reachable. To ensure smooth execution, among the ss chosen cities, any two chosen cities can reach each other without passing through any unchosen city.

Access Globe controls the soldier with the kk-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 SS 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 kk cities are chosen, Access Globe will not be dispatched; in this case the danger level is 00.

Of course, you do not want to solve this problem for him, and you are not going to tell him the remainder modulo 998244353998\,244\,353. You will only tell him the remainder modulo 6412364\,123.

Input Format

The first line contains 33 integers n,k,Wn, k, W, 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 nn integers between 11 and WW, d1,d2,,dnd_1, d_2, \ldots, d_n, denoting the danger level of each city.

Lines 33 through n+1n + 1 each contain two integers xi,yix_i, y_i, indicating that there is a bidirectional road between cities xix_i and yiy_i in country D.

Output Format

Output a single integer: the remainder modulo 6412364\,123 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 dd is drawn as a (d+3)(d + 3)-gon.

All valid choices with at least 33 selected cities are:

  • Choose cities 1,2,31, 2, 3; the danger level for Access Globe’s soldier is 11.
  • Choose cities 1,2,3,41, 2, 3, 4; the danger level is 11.
  • Choose cities 1,2,3,51, 2, 3, 5; the danger level is 11.
  • Choose cities 1,2,3,4,51, 2, 3, 4, 5; the danger level is 22.
  • Choose cities 1,2,41, 2, 4; the danger level is 11.
  • Choose cities 1,2,51, 2, 5; the danger level is 11.
  • Choose cities 1,2,4,51, 2, 4, 5; the danger level is 22.
  • Choose cities 1,4,51, 4, 5; the danger level is 22.
  • When fewer than 33 cities are chosen, the danger level is 00.

Therefore you should output (1+1+1+2+1+1+2+2)mod64123=11(1 + 1 + 1 + 2 + 1 + 1 + 2 + 2) \bmod 64\,123 = 11.

Translated by ChatGPT 5