問題一覧 > 通常問題

No.2484 Add to Variables

レベル : / AI推定難易度 : 2200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 40
作問者 : Magentor / テスター : ytqm3
お気に入りにしたユーザー ProblemId : 10103 / 自分の提出
問題文最終更新日: 2023-11-22 22:18:52
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 405 技術室奥プログラミングコンテスト#7 Day1 (順位表) の他の問題:
Problems F and G share the same setting and differ only in the constraints.

Problem Statement

There is a sequence $A$ of length $N$. Initially, all values of $A$ are $0$.

Consider performing the following $4$ types of operations on this sequence.

  • Do nothing.
  • Choose an integer $k \ (1 \leq k \leq N-1)$, and for every integer $i$ satisfying $1 \leq i \leq k$, add $1$ to $A_i$.
  • Choose an integer $k \ (2 \leq k \leq N)$, and for every integer $i$ satisfying $k \leq i \leq N$, add $1$ to $A_i$.
  • For every integer $i$ satisfying $1 \leq i \leq N$, add $1$ to $A_i$.

Among the ways to perform operations exactly $M$ times, find the number of those that result in $A=B$, modulo $998244353$.

Here, two sequences of operations are considered different if and only if there exists an integer $i$ such that the sets of indices of the numbers to which $1$ was added in the $i$-th operation differ.

Input

The input is given from standard input in the following format.

$N$ $M$
$B_1$ $B_2$ $\ldots$ $B_N$
  • All input values are integers.
  • $N=4$
  • $1 \le M \le 2 \times 10^5$
  • $0 \leq B_i \leq M$

Output

Output the answer.

Sample

Sample 1
Input
4 2
1 1 1 0
Output
2

There are $2$ possible ways: adding $1$ to $A_1,A_2,A_3$ in the $1$-st operation and not adding $1$ to any variable in the $2$-nd operation, and not adding $1$ to any variable in the $1$-st operation and adding $1$ to $A_1,A_2,A_3$ in the $2$-nd operation.

Sample 2
Input
4 2
1 1 1 1
Output
8
Only when $1$ is added to the variables to which $1$ was not added in the $1$-st operation can $A_1=A_2=A_3=A_4=1$ be achieved, so the answer is $8$ ways.
Sample 3
Input
4 3
0 3 2 2
Output
0
Sample 4
Input
4 314
202 3 9 22
Output
362672301

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。