No.2484 Add to Variables
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
8Only 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もしくは右上の雲マークをクリックしてアカウントを作成してください。
Magentor