11150: ABC370 - E - Avoid K Partition
[Creator : ]
Description
You are given a sequence $A = (A_1, A_2, \dots, A_N)$ of length $N$ and an integer $K$.
There are $2^{N-1}$ ways to divide $A$ into several contiguous subsequences. How many of these divisions have no subsequence whose elements sum to $K$? Find the count modulo $998244353$.
Here, "to divide $A$ into several contiguous subsequences" means the following procedure.
- Freely choose the number $k$ $(1 \leq k \leq N)$ of subsequences and an integer sequence $(i_1, i_2, \dots, i_k, i_{k+1})$ satisfying $1 = i_1 \lt i_2 \lt \dots \lt i_k \lt i_{k+1} = N+1$.
- For each $1 \leq n \leq k$, the $n$-th subsequence is formed by taking the $i_n$-th through $(i_{n+1} - 1)$-th elements of $A$, maintaining their order.
Here are some examples of divisions for $A = (1, 2, 3, 4, 5)$:
- $(1, 2, 3), (4), (5)$
- $(1, 2), (3, 4, 5)$
- $(1, 2, 3, 4, 5)$
Input
The input is given from Standard Input in the following format:
$N$ $K$
$A_1$ $A_2$ $\dots$ $A_N$
Output
Print the count modulo $998244353$.
Constraints
- $1 \leq N \leq 2 \times 10^5$
- $-10^{15} \leq K \leq 10^{15}$
- $-10^9 \leq A_i \leq 10^9$
- All input values are integers.
Sample 1 Input
3 3
1 2 3
Sample 1 Output
2
There are two divisions that satisfy the condition in the problem statement:
- $(1), (2, 3)$
- $(1, 2, 3)$
Sample 2 Input
5 0
0 0 0 0 0
Sample 2 Output
0
Sample 3 Input
10 5
-5 -1 -7 6 -6 -2 -5 10 2 -10
Sample 3 Output
428