CF1879C.Make it Alternating
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a binary string s. A binary string is a string consisting of characters 0 and/or 1.
You can perform the following operation on s any number of times (even zero):
- choose an integer i such that 1≤i≤∣s∣, then erase the character si.
You have to make s alternating, i. e. after you perform the operations, every two adjacent characters in s should be different.
Your goal is to calculate two values:
- the minimum number of operations required to make s alternating;
- the number of different shortest sequences of operations that make s alternating. Two sequences of operations are different if in at least one operation, the chosen integer i is different in these two sequences.
给你一个二进制字符串 s。二进制字符串是由字符 0 和/或 1 组成的字符串。
你可以对 s 执行以下操作任意多次(包括零次):
- 选择一个整数 i,满足 1≤i≤∣s∣,然后删除字符 si。
你需要使 s 变为交替字符串,即:执行所有操作后,s 中任意两个相邻字符都必须不同。
你的目标是计算以下两个值:
- 使 s 变为交替字符串所需的最少操作次数;
- 使 s 变为交替字符串的最短操作序列的个数。若两个操作序列在至少一次操作中所选的整数 i 不同,则称这两个序列不同。
输入格式
The first line contains one integer t (1≤t≤104) — the number of test cases.
Each test case consists of one line containing the string s (1≤∣s∣≤2⋅105). The string s consists of characters 0 and/or 1 only.
Additional constraint on the input:
- the total length of strings s over all test cases does not exceed 2⋅105.
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。
每个测试用例由一行组成,该行包含字符串 s(1≤∣s∣≤2⋅105)。字符串 s 仅由字符 0 和/或 1 组成。
输入的额外约束:
- 所有测试用例中字符串 s 的总长度不超过 2⋅105。
输出格式
For each test case, print two integers: the minimum number of operations you have to perform, and the number of different shortest sequences of operations. Since the second number might be large, print its remainder modulo 998244353.
对于每个测试用例,输出两个整数:你需要执行的最少操作次数,以及不同的最短操作序列的数量。由于第二个数可能很大,请输出其对 998244353 取模的结果。
输入输出样例
输入#1
3 10010 111 0101
输出#1
1 2 2 6 0 1
说明/提示
In the first test case of the example, the shortest sequences of operations are:
- [2] (delete the 2-nd character);
- [3] (delete the 3-rd character).
In the second test case of the example, the shortest sequences of operations are:
- [2,1] (delete the 2-nd character, then delete the 1-st character);
- [2,2];
- [1,1];
- [1,2];
- [3,1];
- [3,2].
In the third test case of the example, the only shortest sequence of operations is [] (empty sequence).
在示例的第一个测试用例中,最短的操作序列有:
- [2](删除第 2 个字符);
- [3](删除第 3 个字符)。
在示例的第二个测试用例中,最短的操作序列有:
- [2,1](先删除第 2 个字符,再删除第 1 个字符);
- [2,2];
- [1,1];
- [1,2];
- [3,1];
- [3,2]。
在示例的第三个测试用例中,唯一的最短操作序列是 [](空序列)。
输入解题思路,AI测评打分。不知道怎么写?