CF1608F.MEX counting

NOI/NOI+/CTSC

通过率:0%

时间限制:4.00s

内存限制:256MB

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:

  • 0≤ai≤n0 \le a_i \le n for each ii for each ii from 11 to nn.

  • ∣MEX([a1,a2,…,ai])−bi∣≤k|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 998 244 353998\,244\,353.

对于一个非负整数数组 cc,MEX(c)MEX(c) 表示未在该数组中出现的最小非负整数。例如,MEX([0,1,3])=2MEX([0, 1, 3]) = 2,MEX([42])=0MEX([42]) = 0。

给定整数 n,kn, k 和一个数组 [b1,b2,…,bn][b_1, b_2, \ldots, b_n]。

求满足以下条件的数组 [a1,a2,…,an][a_1, a_2, \ldots, a_n] 的个数:

  • 对每个 ii(1≤i≤n1 \le i \le n),有 0≤ai≤n0 \le a_i \le n;

  • 对每个 ii(1≤i≤n1 \le i \le n),有 ∣MEX([a1,a2,…,ai])−bi∣≤k|MEX([a_1, a_2, \ldots, a_i]) - b_i| \le k。

由于该数目可能非常大,请输出其对 998 244 353998\,244\,353 取模的结果。

输入格式

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

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

输入的第一行包含两个整数 n,kn, k(1≤n≤20001 \le n \le 2000,0≤k≤500 \le k \le 50)。

输入的第二行包含 nn 个整数 b1,b2,…,bnb_1, b_2, \ldots, b_n(−k≤bi≤n+k-k \le b_i \le n+k)—— 数组 bb 的元素。

输出格式

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

输出一个整数——满足题目条件的数组个数对 998 244 353998\,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

输入解题思路,AI测评打分。不知道怎么写?

首页