CF1608F.MEX counting

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

You are given integers n,kn, k , and an array [b1,b2,,bn][b_1, b_2, \ldots, b_n] .

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

  • 0ain0 \le a_i \le n for each ii for each ii from 11 to nn .
  • MEX([a1,a2,,ai])bik|MEX([a_1, a_2, \ldots, a_i]) - b_i| \le k for each ii from 11 to nn .

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

输入格式

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

The second line of the input contains nn integers b1,b2,,bnb_1, b_2, \ldots, b_n ( kbin+k-k \le b_i \le n+k ) — elements of the array bb .

输出格式

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

输入输出样例

  • 输入#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
首页