CF1930I.Counting Is Fun

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a binary ^\dagger pattern pp of length nn .

A binary string qq of the same length nn is called good if for every ii ( 1in1 \leq i \leq n ), there exist indices ll and rr such that:

  • 1lirn1 \leq l \leq i \leq r \leq n , and
  • pip_i is a mode ^\ddagger of the string qlql+1qrq_lq_{l+1}\ldots q_r .

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

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

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

输入格式

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

The second line of input contains a binary string pp of length nn consisting of characters 0 and 1.

输出格式

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

输入输出样例

  • 输入#1

    1
    0

    输出#1

    1
  • 输入#2

    3
    111

    输出#2

    5
  • 输入#3

    4
    1011

    输出#3

    9
  • 输入#4

    6
    110001

    输出#4

    36
  • 输入#5

    12
    111010001111

    输出#5

    2441

说明/提示

In the second example, the good strings are

  • 010\mathtt{010} ;
  • 011\mathtt{011} ;
  • 101\mathtt{101} ;
  • 110\mathtt{110} ;
  • 111\mathtt{111} .
首页