CF1608F.MEX counting
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:256MB
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.
对于一个非负整数数组 c,MEX(c) 表示未在该数组中出现的最小非负整数。例如,MEX([0,1,3])=2,MEX([42])=0。
给定整数 n,k 和一个数组 [b1,b2,…,bn]。
求满足以下条件的数组 [a1,a2,…,an] 的个数:
-
对每个 i(1≤i≤n),有 0≤ai≤n;
-
对每个 i(1≤i≤n),有 ∣MEX([a1,a2,…,ai])−bi∣≤k。
由于该数目可能非常大,请输出其对 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.
输入的第一行包含两个整数 n,k(1≤n≤2000,0≤k≤50)。
输入的第二行包含 n 个整数 b1,b2,…,bn(−k≤bi≤n+k)—— 数组 b 的元素。
输出格式
Output a single integer — the number of arrays which satisfy the conditions from the statement, modulo 998244353.
输出一个整数——满足题目条件的数组个数对 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
输入解题思路,AI测评打分。不知道怎么写?