knightnemo commited on
Commit
9f3f15b
·
verified ·
1 Parent(s): 4969bcd

Upload code_segments/segment_91.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_91.txt +23 -0
code_segments/segment_91.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The two versions of the problem are different. You may want to read both versions. You can make hacks only if both versions are solved.
2
+
3
+ You are given an array $a$ of length $n$. Start with $c = 0$. Then, for each $i$ from $1$ to $n$ (in increasing order) do exactly one of the following:
4
+
5
+ * Option $1$: set $c$ to $c + a_i$. * Option $2$: set $c$ to $|c + a_i|$, where $|x|$ is the absolute value of $x$.
6
+
7
+ Let the maximum final value of $c$ after the procedure described above be equal to $k$. Find the number of unique procedures that result in $c = k$. Two procedures are different if at any index $i$, one procedure chose option $1$ and another chose option $2$, even if the value of $c$ is equal for both procedures after that turn.
8
+
9
+ Since the answer may be large, output it modulo $998\,244\,353$.
10
+
11
+ The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.
12
+
13
+ The first line of each test case contains a single integer $n$ ($2 \leq n \leq 2 \cdot 10^5$).
14
+
15
+ The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($-10^9 \leq a_i \leq 10^9$).
16
+
17
+ The sum of $n$ over all test cases does not exceed $3 \cdot 10^5$.
18
+
19
+ For each test case, output a single integer — the number of unique procedures that result in $c = k$, modulo $998\,244\,353$.
20
+
21
+ In the first test case, it can be shown that our maximal final value of $c$ is $3$. There are $12$ ways to achieve this because in order to get $3$, we have to take absolute value at indices $2$ or $4$, or both, resulting in $3$ ways. For the other two indices, it doesn't change the value whether we take absolute value or not, so we have $2 \cdot 2 = 4$ ways for them. In total, we have $3 \cdot 4 = 12$ ways.
22
+
23
+ In the second test case, taking the absolute value will never change anything, so we can either take absolute value or not, for every index. This gives us $2^8 = 256$ possible ways.