#P15740. [JAG 2024 Summer Camp #2] Linear Time Inversion Number
[JAG 2024 Summer Camp #2] Linear Time Inversion Number
题目描述
Given a permutation of length , Alice uses the inversion number as a measure of how close is to the permutation , while Bob uses the metric .
Here, the inversion number is the number of pairs such that and .
Given a sequence of length , there are permutations of length that have as their prefix.
Find the number of these permutations for which Alice's metric and Bob's metric are equal, and return the result modulo .
输入格式
The input is given in the following format:
$$\begin{aligned} &N \ K \\ &A_1 \ A_2 \ \ldots \ A_K \end{aligned} $$- All input values are integers.
输出格式
Output the answer.
5 3
2 3 5
1
10 10
3 1 4 5 9 2 6 8 7 10
0
6 0
132