Codeforces Round 1077 (Div. 2)
F
Cool Problem
Codeforces
未评级
原题
← EG →
翻译中…

There are two integer constants $x$ and $y$.

翻译中…

For a binary$^{\text{∗}}$ string $r$ of length $n$, we define its generating array as an array $c=[c_0,c_1,\ldots,c_n]$ such that $c_0=0$, and for each $1 \le i \le n$:

翻译中…
  • If $r_i=\mathtt{0}$, then $c_i=x+c_{i-1}$;
  • If $r_i=\mathtt{1}$, then $c_i=y-c_{i-1}$.
翻译中…

Additionally, we define $f(r)=\sum\limits_{i=1}^n c_i$.

翻译中…

You are given an incomplete binary string $s$ of length $n$, where some characters in it are missing, represented by $\mathtt{?}$. An integer $k$ is called cool if and only if there exists a way to replace each $\mathtt{?}$ in $s$ with either $\mathtt{0}$ or $\mathtt{1}$, such that $f(s)=k$.

翻译中…

Your task is to calculate the sum of all cool integers, modulo $998\,244\,353$.

翻译中…

$^{\text{∗}}$A binary string is a string where each character is either $\mathtt{0}$ or $\mathtt{1}$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $x$, and $y$ ($1 \le n \le 10^5$, $1 \le x,y \le 10^6$) — the length of $s$ and the given constants.

翻译中…

The second line contains the incomplete binary string $s$ of length $n$ ($s_i \in \{\mathtt{0}, \mathtt{1}, \mathtt{?}\}$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each test case, output a single integer — the sum of all cool integers modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first test case, the string $s$ has already been determined, and its generating array is $[0, 1]$. Thus, $f(s)=1$, and the only cool integer is $1$.

翻译中…

In the third test case, there are four ways to complete the string $s$:

翻译中…

$s$Generating array$f(s)$$\mathtt{000}$$[0, 7, 14, 21]$$42$$\mathtt{001}$$[0, 7, 14, -9]$$12$$\mathtt{100}$$[0, 5, 12, 19]$$36$$\mathtt{101}$$[0, 5, 12, -7]$$10$

翻译中…

Thus, the sum of all cool integers is $42+12+36+10=100$.

翻译中…

样例

Input #1
4
1 1 2
0
1 1 2
?
3 7 5
?0?
7 114514 191981
?1?????
Output #1
1
3
100
8039591
InputCopy OutputCopy
题目信息
题号
2188F
时间限制
4 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。