409828: GYM103800 E Ginger's coloring

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Ginger's coloringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Given an permutation $$$p_1, p_2, \dots,p_n$$$ of length $$$n$$$, now color each number from $$$1$$$ to $$$n$$$ in black and white.

Define $$$\texttt{Ginger coloring}$$$ as:

for all $$$i$$$ $$$(1 \le i \le n)$$$, the color of $$$i$$$ not equal to the color of $$$p_i$$$.

How many ways of coloring make permutation $$$p$$$ become $$$\texttt{Ginger coloring}$$$ modulo $$$998\,244\,353$$$.

Input

The first line contains a integer $$$n$$$ $$$(1 \le n \le 10 ^ 5)$$$ indicating the lenth of permutation.

The next line contains $$$n$$$ integers $$$p_1,p_2,\cdots,p_n$$$ $$$(1 \le p_i \le n)$$$ indicating the permutation.

Output

Output the ways of coloring modulo $$$998\,244\,353$$$.

ExampleInput
6
2 3 4 1 6 5
Output
4

加入题单

上一题 下一题 算法标签: