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$$$.
InputThe 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.
OutputOutput the ways of coloring modulo $$$998\,244\,353$$$.
ExampleInput6 2 3 4 1 6 5Output
4