CF1879C.Make it Alternating

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given a binary string ss . A binary string is a string consisting of characters 0 and/or 1.

You can perform the following operation on ss any number of times (even zero):

  • choose an integer ii such that 1is1 \le i \le |s| , then erase the character sis_i .

You have to make ss alternating, i. e. after you perform the operations, every two adjacent characters in ss should be different.

Your goal is to calculate two values:

  • the minimum number of operations required to make ss alternating;
  • the number of different shortest sequences of operations that make ss alternating. Two sequences of operations are different if in at least one operation, the chosen integer ii is different in these two sequences.

输入格式

The first line contains one integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases.

Each test case consists of one line containing the string ss ( 1s21051 \le |s| \le 2 \cdot 10^5 ). The string ss consists of characters 0 and/or 1 only.

Additional constraint on the input:

  • the total length of strings ss over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

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 998244353998244353 .

输入输出样例

  • 输入#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][2] (delete the 22 -nd character);
  • [3][3] (delete the 33 -rd character).

In the second test case of the example, the shortest sequences of operations are:

  • [2,1][2, 1] (delete the 22 -nd character, then delete the 11 -st character);
  • [2,2][2, 2] ;
  • [1,1][1, 1] ;
  • [1,2][1, 2] ;
  • [3,1][3, 1] ;
  • [3,2][3, 2] .

In the third test case of the example, the only shortest sequence of operations is [][] (empty sequence).

首页