atcoder#AGC038B. [AGC038B] Sorting a Segment
[AGC038B] Sorting a Segment
Score : points
Problem Statement
Snuke has a permutation of .
Now, he will perform the following operation exactly once:
- Choose consecutive elements in and sort them in ascending order.
Find the number of permutations that can be produced as after the operation.
Constraints
- are all different.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of permutations that can be produced as after the operation.
5 3
0 2 1 4 3
2
Two permutations can be produced as after the operation: and .
4 4
0 1 2 3
1
10 4
2 0 1 3 7 5 4 6 8 9
6