#P4223. 期望逆序对
期望逆序对
Description
The monastery led by mcfx attempts to summon the legendary “memetic master” WXH through an ancient ritual array. After preparing all the summoning tools, mcfx activates the array to the clatter of many keyboards.
Suddenly, heaven and earth darken, and lightning strikes the center of the array. A golden beam descends from the sky, with golden code drifting in midair. Soon, a login interface appears. Upon careful inspection, mcfx sees the following text:
"WXHCoder is a problem bank that contains every problem from the past to the future. If you want to log into it, you must solve the following problem."
The problem is as follows: You are given a permutation of length . There are operations. In each operation, two distinct numbers are chosen uniformly at random and swapped. Find the expected number of inversions multiplied by .
mcfx discovered that the Constraints are , so he decides to first explore smaller .
denotes the number of ways to choose two from balls.
Input Format
The first line contains two integers .
The second line contains a permutation of through .
Output Format
Output the expected number of inversions multiplied by modulo .
5 4
1 5 4 3 2
50000
Hint
.
Translated by ChatGPT 5
京公网安备 11011102002149号