atcoder#ARC154E. [ARC154E] Reverse and Inversion
[ARC154E] Reverse and Inversion
Score : points
Problem Statement
For a permutation of , let be the following value:
$$j-i$$$$(i,j)$$$$1 \le i < j \le N$$$$Q_i > Q_j$$You are given a permutation $P=(P_1,P_2,\dots,P_N)$ of $(1,2,\dots,N)$. $$>
Let us repeat the following operation times.
- Choose a pair of integers such that . Reverse . Formally, replace the values of with simultaneously.
There are ways to repeat the operation. Assume that we have computed for all those ways.
Find the sum of these values, modulo .
Constraints
- is a permutation of .
Input
The input is given from Standard Input in the following format:
Output
Print a single line containing the answer.
2 1
1 2
1
There are three ways to perform the operation, as follows.
- Choose , making , where .
- Choose , making , where .
- Choose , making , where .
Thus, the answer is .
3 2
3 2 1
90
10 2023
5 8 1 9 3 10 4 7 2 6
543960046