CF1608F.MEX counting
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 [b1,b2,…,bn] .
Find the number of arrays [a1,a2,…,an] , for which the following conditions hold:
- 0≤ai≤n for each i for each i from 1 to n .
- ∣MEX([a1,a2,…,ai])−bi∣≤k for each i from 1 to n .
As this number can be very big, output it modulo 998244353 .
输入格式
The first line of the input contains two integers n,k ( 1≤n≤2000 , 0≤k≤50 ).
The second line of the input contains n integers b1,b2,…,bn ( −k≤bi≤n+k ) — elements of the array b .
输出格式
Output a single integer — the number of arrays which satisfy the conditions from the statement, modulo 998244353 .
输入输出样例
输入#1
4 0 0 0 0 0
输出#1
256
输入#2
4 1 0 0 0 0
输出#2
431
输入#3
4 1 0 0 1 1
输出#3
509
输入#4
5 2 0 0 2 2 0
输出#4
6546
输入#5
3 2 -2 0 4
输出#5
11