think-cell Round 1
I
Counting Is Fun
Codeforces
3500
原题
← H→
翻译中…

You are given a binary$^\dagger$ pattern $p$ of length $n$.

翻译中…

A binary string $q$ of the same length $n$ is called good if for every $i$ ($1 \leq i \leq n$), there exist indices $l$ and $r$ such that:

翻译中…
  • $1 \leq l \leq i \leq r \leq n$, and
  • $p_i$ is a mode$^\ddagger$ of the string $q_lq_{l+1}\ldots q_r$.
翻译中…

Count the number of good binary strings modulo $998\,244\,353$.

翻译中…

$^\dagger$ A binary string is a string that only consists of characters $\mathtt{0}$ and $\mathtt{1}$.

翻译中…

$^\ddagger$ Character $c$ is a mode of string $t$ of length $m$ if the number of occurrences of $c$ in $t$ is at least $\lceil \frac{m}{2} \rceil$. For example, $\mathtt{0}$ is a mode of $\mathtt{010}$, $\mathtt{1}$ is not a mode of $\mathtt{010}$, and both $\mathtt{0}$ and $\mathtt{1}$ are modes of $\mathtt{011010}$.

翻译中…

Input

翻译中…

The first line of input contains a single integer $n$ ($1 \le n \le 10^5$) — the length of the binary string $p$.

翻译中…

The second line of input contains a binary string $p$ of length $n$ consisting of characters 0 and 1.

翻译中…

Output

翻译中…

Output the number of good strings modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the second example, the good strings are

翻译中…
  • $\mathtt{010}$;
  • $\mathtt{011}$;
  • $\mathtt{101}$;
  • $\mathtt{110}$;
  • $\mathtt{111}$.
翻译中…

样例

Input #1
1
0
Output #1
1
InputCopy OutputCopy
Input #2
3
111
Output #2
5
InputCopy OutputCopy
Input #3
4
1011
Output #3
9
InputCopy OutputCopy
Input #4
6
110001
Output #4
36
InputCopy OutputCopy
Input #5
12
111010001111
Output #5
2441
InputCopy OutputCopy
题目信息
题号
1930I
所属比赛
时间限制
3 s
内存限制
256 MB
标签
组合数学

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