Codeforces Round 758 (Div.1 + Div. 2)
F
MEX counting
Codeforces
3200
原题
← EG →
翻译中…

For an array $c$ of nonnegative integers, $MEX(c)$ denotes the smallest nonnegative integer that doesn't appear in it. For example, $MEX([0, 1, 3]) = 2$, $MEX([42]) = 0$.

翻译中…

You are given integers $n, k$, and an array $[b_1, b_2, \ldots, b_n]$.

翻译中…

Find the number of arrays $[a_1, a_2, \ldots, a_n]$, for which the following conditions hold:

翻译中…
  • $0 \le a_i \le n$ for each $i$ for each $i$ from $1$ to $n$.
  • $|MEX([a_1, a_2, \ldots, a_i]) - b_i| \le k$ for each $i$ from $1$ to $n$.
翻译中…

As this number can be very big, output it modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first line of the input contains two integers $n, k$ ($1 \le n \le 2000$, $0 \le k \le 50$).

翻译中…

The second line of the input contains $n$ integers $b_1, b_2, \ldots, b_n$ ($-k \le b_i \le n+k$) — elements of the array $b$.

翻译中…

Output

翻译中…

Output a single integer — the number of arrays which satisfy the conditions from the statement, modulo $998\,244\,353$.

翻译中…

样例

Input #1
4 0
0 0 0 0
Output #1
256
InputCopy OutputCopy
Input #2
4 1
0 0 0 0
Output #2
431
InputCopy OutputCopy
Input #3
4 1
0 0 1 1
Output #3
509
InputCopy OutputCopy
Input #4
5 2
0 0 2 2 0
Output #4
6546
InputCopy OutputCopy
Input #5
3 2
-2 0 4
Output #5
11
InputCopy OutputCopy
题目信息
题号
1608F
时间限制
4 s
内存限制
256 MB
标签
组合数学
动态规划
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。