CF1930I.Counting Is Fun
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:256MB
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.
给你一个长度为 n 的二进制† 模式串 p。
一个长度同样为 n 的二进制字符串 q 被称为好串,当且仅当对每个 i(1≤i≤n),均存在下标 l 和 r,满足:
- 1≤l≤i≤r≤n,且
- pi 是子串 qlql+1…qr 的一个众数‡。
求好串的个数,对 998244353 取模。
† 二进制字符串是指仅由字符 0 和 1 组成的字符串。
‡ 字符 c 是长度为 m 的字符串 t 的众数,当且仅当 c 在 t 中的出现次数至少为 ⌈2m⌉。例如,0 是 010 的众数,1 不是 010 的众数,而 0 和 1 都是 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.
输入的第一行包含一个整数 n(1≤n≤105)——即二进制字符串 p 的长度。
输入的第二行包含一个长度为 n 的二进制字符串 p,由字符 0 和 1 组成。
输出格式
Output the number of good strings modulo 998244353.
输出好字符串的数量对 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.
在第二个例子中,好的字符串有:
- 010;
- 011;
- 101;
- 110;
- 111。
输入解题思路,AI测评打分。不知道怎么写?