CF1329D.Dreamoon Likes Strings

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Dreamoon likes strings. Today he created a game about strings:

String s1,s2,,sns_1, s_2, \ldots, s_n is beautiful if and only if for each 1i<n,sisi+11 \le i < n, s_i \ne s_{i+1} .

Initially, Dreamoon has a string aa . In each step Dreamoon can choose a beautiful substring of aa and remove it. Then he should concatenate the remaining characters (in the same order).

Dreamoon wants to use the smallest number of steps to make aa empty. Please help Dreamoon, and print any sequence of the smallest number of steps to make aa empty.

输入格式

The first line contains an integer tt ( 1t2000001 \leq t \leq 200\,000 ), denoting the number of test cases in the input.

For each test case, there's one line with a non-empty string of lowercase Latin letters aa .

The total sum of lengths of strings in all test cases is at most 200000200\,000 .

输出格式

For each test case, in the first line, you should print mm : the smallest number of steps to make aa empty. Each of the following mm lines should contain two integers li,ril_i, r_i ( 1liria1 \leq l_i \leq r_i \leq |a| ), denoting, that the ii -th step is removing the characters from index lil_i to rir_i in the current string. (indices are numbered starting from 11 ).

Note that after the deletion of the substring, indices of remaining characters may change, and rir_i should be at most the current length of aa .

If there are several possible solutions, you can print any.

输入输出样例

  • 输入#1

    4
    aabbcc
    aaabbb
    aaa
    abacad

    输出#1

    3
    3 3
    2 4
    1 2
    3
    3 4
    2 3
    1 2
    3
    1 1
    1 1
    1 1
    1
    1 6
首页