#P10741. [SEERC 2020] Fence Job
[SEERC 2020] Fence Job
Problem Description
Fred has a permutation of length . In each operation, he can choose an interval and set .
After performing several operations (possibly operations), find the number of distinct arrays that can be obtained, modulo .
Input Format
The first line contains an integer .
The next line contains integers .
Output Format
Output the number of distinct arrays after the operations modulo .
3
1 3 2
4
5
1 2 3 4 5
42
7
1 4 2 5 3 6 7
124
Hint
Translated by ChatGPT 5