CF1329D.Dreamoon Likes Strings
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Dreamoon likes strings. Today he created a game about strings:
String s1,s2,…,sn is beautiful if and only if for each 1≤i<n,si=si+1.
Initially, Dreamoon has a string a. In each step Dreamoon can choose a beautiful substring of a 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 a empty. Please help Dreamoon, and print any sequence of the smallest number of steps to make a empty.
Dreamoon 喜欢字符串。今天他设计了一个关于字符串的游戏:
当且仅当对每个 1≤i<n 都有 si=si+1 时,字符串 s1,s2,…,sn 被称为“优美的”。
初始时,Dreamoon 拥有一个字符串 a。在每一步中,Dreamoon 可以选择 a 的一个优美子串并将其删除;然后他需将剩余字符(保持原有顺序)拼接起来。
Dreamoon 希望用最少的步数将 a 变为空字符串。请帮助 Dreamoon,输出任意一种达到最少步数的删除操作序列。
输入格式
The first line contains an integer t (1≤t≤200000), 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 a.
The total sum of lengths of strings in all test cases is at most 200000.
第一行包含一个整数 t(1≤t≤200000),表示输入中测试用例的数量。
对于每个测试用例,有一行,包含一个非空的、由小写拉丁字母组成的字符串 a。
所有测试用例中字符串长度的总和不超过 200000。
输出格式
For each test case, in the first line, you should print m: the smallest number of steps to make a empty. Each of the following m lines should contain two integers li,ri (1≤li≤ri≤∣a∣), denoting, that the i-th step is removing the characters from index li to ri in the current string. (indices are numbered starting from 1).
Note that after the deletion of the substring, indices of remaining characters may change, and ri should be at most the current length of a.
If there are several possible solutions, you can print any.
对于每个测试用例,第一行应输出 m:使字符串 a 为空所需的最少操作步数。接下来的 m 行每行应包含两个整数 li,ri(满足 1≤li≤ri≤∣a∣),表示第 i 步操作为删除当前字符串中从索引 li 到 ri 的所有字符(索引从 1 开始编号)。
注意:在子串被删除后,剩余字符的索引会发生变化,且 ri 应不超过当前字符串 a 的长度。
若存在多种可行解,输出任意一种即可。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?