AtCoder Regular Contest 114
翻译中…
Problem Statement
翻译中…
Let $S$ be a set composed of all integers from $1$ through $N$.
翻译中…
$f$ is a function from $S$ to $S$. You are given the values $f(1), f(2), \cdots, f(N)$ as $f_1, f_2, \cdots, f_N$.
翻译中…
Find the number, modulo $998244353$, of non-empty subsets $T$ of $S$ satisfying both of the following conditions:
翻译中…
- For every
$a \in T$,$f(a) \in T$. - For every
$a, b \in T$,$f(a) \neq f(b)$if$a \neq b$.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 2 \times 10^5$$1 \leq f_i \leq N$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
f_1 f_2 \ldots f_N
翻译中…
Output
翻译中…
Print the number of non-empty subsets of $S$ satisfying both of the conditions, modulo $998244353$.
翻译中…
样例
Input #1
2
2 1
Output #1
1
We have $f(1) = 2, f(2) = 1$. Since $f(1) \neq f(2)$, the second condition is always satisfied, but the first condition requires $T$ to contain $1$ and $2$ simultaneously.
Input #2
2
1 1
Output #2
1
We have $f(1) = f(2) = 1$. The first condition requires $T$ to contain $1$, and the second condition forbids $T$ to contain $2$.
Input #3
3
1 2 3
Output #3
7
We have $f(1) = 1, f(2) = 2, f(3) = 3$. Both of the conditions are always satisfied, so all non-empty subsets of $T$ count.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。