CF1930I.Counting Is Fun
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a binary † pattern p of length n .
A binary string q of the same length n is called good if for every i ( 1≤i≤n ), there exist indices l and r such that:
- 1≤l≤i≤r≤n , and
- pi is a mode ‡ of the string qlql+1…qr .
Count the number of good binary strings modulo 998244353 .
† A binary string is a string that only consists of characters 0 and 1 .
‡ Character c is a mode of string t of length m if the number of occurrences of c in t is at least ⌈2m⌉ . For example, 0 is a mode of 010 , 1 is not a mode of 010 , and both 0 and 1 are modes of 011010 .
输入格式
The first line of input contains a single integer n ( 1≤n≤105 ) — 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 the number of good strings modulo 998244353 .
输入输出样例
输入#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 ;
- 011 ;
- 101 ;
- 110 ;
- 111 .