{"problem":{"name":"Typical Permutation Descriptor","description":{"content":"You are given a sequence of integers $(A_1,\\dots,A_N)$ of length $N$. This sequence satisfies $0\\le A_i < i$ for each $i=1,\\dots,N$. Find the number of permutations $(P_1,\\dots,P_N)$ of $(1,\\dots,N)$ ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc186_b"},"statements":[{"statement_type":"Markdown","content":"You are given a sequence of integers $(A_1,\\dots,A_N)$ of length $N$. This sequence satisfies $0\\le A_i < i$ for each $i=1,\\dots,N$. Find the number of permutations $(P_1,\\dots,P_N)$ of $(1,\\dots,N)$ that satisfy the following conditions, modulo $998244353$.\n\n*   For each $i=1,\\dots,N$:\n    *   $P_j > P_i$ for any integer $j$ with $A_i < j < i$\n    *   $P_{A_i} < P_i$ if $A_i > 0$\n\nFor the sequence $(A_1,\\dots,A_N)$ given in the input, it is guaranteed that there exists a permutation satisfying the conditions.\n\n## Constraints\n\n*   $1\\le N\\le 3\\times 10^5$\n*   $0\\le A_i \\lt i$\n*   For $A_1,\\dots,A_N$, there exists a permutation satisfying the conditions in the problem statement.\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc186_b","tags":[],"sample_group":[["4\n0 1 0 3","3\n\nThere are three such permutations: $(2, 3, 1, 4)$, $(2, 4, 1, 3)$, and $(3, 4, 1, 2)$."],["22\n0 1 2 2 2 2 2 2 1 9 9 9 9 0 14 15 15 15 14 19 19 19","353820794\n\nThe answer is $353820794$, which is $2350309500$ modulo $998244353$."]],"created_at":"2026-03-03 11:01:14"}}