#P8478. 「GLR-R3」清明

「GLR-R3」清明

Background

  "       ,       "


  "You keep saying this is not my true strength, so why can't one accidental wrong note ruin my fate?!"

  Tianyi did not notice that the person she was crying out to in her heart, like her, was holding an umbrella, only a dozen steps behind her.


  Qingming "In the abyss called weakness, what have you actually seen?"

Problem Description

Raindrops hit the window ledges, falling down step by step.

There are nn window ledges in total, numbered from top to bottom. The highest ledge is numbered 11, and the lowest ledge is numbered nn. Suppose that at some instant, there are aia_i units of rainwater on ledge ii. Due to some magical physical reasons, the rainwater on ledge ii will, in the "next instant", drip to ledges i+1,i+2,,min{i+k,n}i+1,i+2,\dots,\min\{i+k,n\}, or it may stay on ledge ii. For each possible destination, the amount of water (in units of volume) must be a non-negative integer, and the total must be aia_i.

Let aia_i' be the amount of rainwater on ledge ii in the "next instant". Then the magic value of the rainwater at that time is defined as i=1nai\prod_{i=1}^n a_i'. Now, the sad person wants to know: among all essentially different "next instants", what is the sum of the magic values modulo the prime P=998244353P=998244353?

Two "next instants" are essentially different if and only if there exist two ledges with indices i<ji<j such that the amount of water dripping from ledge ii to ledge jj is different.

Input Format

The first line contains two positive integers n,kn,k, representing the number of window ledges and the constant that limits the dripping distance.

The second line contains nn non-negative integers a1,a2,a3,,ana_1,a_2,a_3,\cdots,a_n, where aia_i is the volume of rainwater on ledge ii at the current instant.

Output Format

Output one integer in one line, representing the sum of the magic values over all essentially different "next instants", taken modulo PP.

3 0
2 2 2
8
3 1
2 2 2
30
5 3
2 3 4 4 3
275200

Hint

Sample #1 Explanation.

It is easy to see that there is only one essentially different "next instant": no ledge drips any water to other ledges.

So finally a={2,2,2}a'=\{2,2,2\}, and the value is 88.

Sample #2 Explanation.

Let ckc_k denote the volume of rain dripping from ledge kk to ledge k+1k+1. Clearly, c3=0c_3=0.

Enumerate all valid dripping situations:

  • c={0,0,0},b={2,2,2}c=\{0,0,0\},b=\{2,2,2\}, value 88;
  • c={0,1,0},b={2,1,3}c=\{0,1,0\},b=\{2,1,3\}, value 66;
  • c={0,2,0},b={2,0,4}c=\{0,2,0\},b=\{2,0,4\}, value 00;
  • c={1,0,0},b={1,3,2}c=\{1,0,0\},b=\{1,3,2\}, value 66;
  • c={1,1,0},b={1,2,3}c=\{1,1,0\},b=\{1,2,3\}, value 66;
  • c={1,2,0},b={1,1,4}c=\{1,2,0\},b=\{1,1,4\}, value 44;
  • c1=2c_1=2. In this case, b1=0b_1=0 must hold, and the values of the three plans in this case are all 00.

Therefore, the total sum of values over all essentially different "next instants" is 8+6+0+6+6+4+0+0+0=308+6+0+6+6+4+0+0+0=30.

Constraints

This problem uses Subtask-based scoring.

For 100%100\% of the testdata, 0k<n320\le k<n\le 32, and 0ai<P0\le a_i<P.

For different subtasks, the constraints are as follows:

Subtask ID nn kk maxai\max a_i Score
11 32\le32 <n<n =0=0 22
22 =0=0 <P<P
33 <n<n =1=1 33
44 5\le5 4\le4 2020
55 32\le32 =1=1 <P<P 1313
66 =n1=n-1 1010
77 16\le16 2020
88 25\le25 <n<n 1010
99 32\le32 2020

Translated by ChatGPT 5