#P3322. [SDOI2015] 排序
[SDOI2015] 排序
Description
Xiao A has a permutation through of through . He wants to sort array in ascending order. Xiao A can perform types of operations, and each type can be used at most once. For every (), the -th operation splits the sequence from left to right into blocks, each containing exactly numbers, and then swaps two of these blocks as a whole.
Xiao A wants to know how many different sequences of operations can sort array in ascending order. Two sequences of operations are considered different if and only if the number of operations is different, or at least one operation is different (either the type or the positions are different).
Here is an example of operations: , .
- First operation: perform the 3rd operation, swap A[1..4] and A[5..8]. After the swap, .
- Second operation: perform the 1st operation, swap A[3] and A[5]. After the swap, .
- Third operation: perform the 2nd operation, swap A[1..2] and A[7..8]. After the swap, .
Input Format
The first line contains an integer .
The second line contains integers, through .
Output Format
Output a single integer denoting the answer.
3
7 8 5 6 1 2 4 3
6
Hint
Constraints: For 100% of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号