Problem Statement
‘Cause morning rolls around, and it’s another day of sun!
But as a sleep addict, Sean spends lots of hours sleeping, and thus, he can’t even remember which day it is when he wakes up.
So starting from someday, he started taking notes: when he wakes up, he writes a number about whether there’s sunlight outside. If there is, he will write a $1$ on it; otherwise, he will write a $0$ . And after taking notes, without enough time for sunlight to fade or for moonlight to dim, he falls asleep again. We assume that every time Sean wakes up, he sees either the sunlight or the moonlight, but not both.
So the notes actually form an array of length $n$ : $[a_1,a_2,\dots,a_n]\ (\forall 1\leq i\leq n, 0\leq a_i\leq 1)$ , where $a_i$ represents the $i$-th number Sean wrote.
However, as time goes on, some numbers written become ambiguous and are just impossible to identify, and you can’t really tell whether it is a $1$ or a $0$ . So if there are $k$ numbers that you can’t identify, there can be $2^k$ different arrays.
For each array, you can calculate the minimum number of days on which Sean sees the sunlight at least once that is consistent with the notes the array represents. If you add the results of different arrays together, what will you get? As the answer can get quite enormous, output it modulo $998\ 244\ 353$ .
Note that we only care about the minimum number of days when the notes with number $1$ are taken.
Input
Each test contains multiple test cases. The first line contains the number of test cases $T\ (1≤T≤10^4)$ .
Each test case consists of two lines.
The first line contains one integer $n\ (2\leq n\leq 5\times 10^5)$, the number of notes.
The second line contains $n$ integers $a_1,a_2,\dots,a_n\ (-1\leq a_i\leq 1)$, each number written on the note. The number is unknown if and only if $a_i=-1$.
It is guaranteed that $\sum n$ over all test cases in one test will not exceed $5\times 10^5$.
Output
For each test case, output $1$ integer: the sum of results modulo $998\ 244\ 353$ .
Solving
|
|