#P4709. 信息传递
信息传递
Description
Given a permutation
$$f = \begin{pmatrix} 1 & 2 & ... & n \\\ a_1 & a_2 & ... & a_n \end{pmatrix}$$find how many permutations satisfy
Output the answer modulo .
Input Format
The first line contains an integer .
The second line contains integers .
Output Format
Output the answer.
3
2 1 3
1
Hint
Sample explanation:
There is only one permutation with that satisfies
$${\begin{pmatrix} 1 & 2 & 3 \\ 2 & 1 & 3 \end{pmatrix}} ^ 3 = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 1 & 3 \end{pmatrix}$$Constraints:
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号