| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 27 | 5 | 5 | 19.231% |
For a string $s_1\dots s_n$ of $n$ bits (i.e., zeros and ones), Bobo computes the $f$-value of $s_1\dots s_n$ by playing the following game.
Formally,
Now, Bobo has a bit string $s_1 \dots s_n$ subjecting to $q$ changes, where the $i$-th change is to flip all the bits among $s_{l_i} \dots s_{r_i}$ for given $l_i,ドル $r_i$. Find the $f$-value modulo 998244353ドル$ of the bit string after each change.
The input consists of several test cases terminated by end-of-file. For each test case,
The first line contains two integers $n$ and $q$.
The second line contains $n$ bits $s_1 \dots s_n$.
For the following $q$ lines, the $i$-th line contains two integers $l_i$ and $r_i$.
For each change, output an integer which denotes the $f$-value modulo 998244353ドル$.
3 2 010 1 2 2 3 5 1 00000 1 5
1 3 5
For the first test case, the string becomes "100" after the first change. $f($100$) = f($000$) + 1 = 1$. And it becomes "111" after the second change. $f($111$) = f($110$) + 1 = f($100$) + 2 = f($000$) + 3 = 3$.