AtCoder Regular Contest 146
翻译中…
Problem Statement
翻译中…
You are given a sequence of $N$ positive integers: $A=(A_1,A_2,\dots,A_N)$.
翻译中…
How many integer sequences $B$ consisting of integers between $1$ and $N$ (inclusive) satisfy all of the following conditions? Print the count modulo $998244353$.
翻译中…
- For each integer
$i$such that$1 \le i \le N$, there are exactly$A_i$occurrences of$i$in$B$. - For each integer
$i$such that$1 \le i \le |B|-1$, it holds that$|B_i - B_{i+1}|=1$.
翻译中…
Constraints
翻译中…
$1 \le N \le 2 \times 10^5$$1 \le A_i \le 2 \times 10^5$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 \dots A_N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
3
2 3 1
Output #1
6
$B$ can be the following six sequences.
- $(1,2,1,2,3,2)$
- $(1,2,3,2,1,2)$
- $(2,1,2,1,2,3)$
- $(2,1,2,3,2,1)$
- $(2,3,2,1,2,1)$
- $(3,2,1,2,1,2)$
Thus, the answer is $6$.
Input #2
1
200000
Output #2
0
There may be no sequence that satisfies the conditions.
Input #3
6
12100 31602 41387 41498 31863 12250
Output #3
750337372
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。