#P15072. [ICPC 2024 Chengdu R] Arrow a Row
[ICPC 2024 Chengdu R] Arrow a Row
题目描述
Define an "arrow string" as a string that meets the following conditions:
- The length of the string is at least .
- The string starts with and ends with .
- The rest of the string consists only of .
For example, and are valid arrow strings, while and are not.
Sauden gives you a string of length , consisting of and . You need to create by performing a series of painting operations on a string of the same length that consists entirely of . In one painting operation, you can choose a substring of length at least and transform it into an arrow string. The total number of operations you perform cannot exceed .
If it is impossible to obtain the string using no more than painting operations, output . Otherwise, output and provide the details of the painting operations. If there are multiple solutions, output any.
输入格式
The first line contains a single integer (), indicating the number of test cases.
Each test case contains a string of length () in a single line, consisting only of and .
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, if the given string cannot be obtained by performing no more than painting operations, output in a single line. Otherwise, output and a positive integer (), which denotes the number of painting operations to perform. Then output lines, each contains two integers () and (), indicating the starting position of the selected substring and its length.
4
>>->>>
>>>->
>>>>>
>->>>>>>
Yes 2
1 5
2 5
No
No
Yes 2
2 7
1 5
提示
For the fourth test case in the example, the painting process is shown below:
:::align{center} $\tt{*}\underline{\tt{>}\tt{-}\tt{-}\tt{-}\tt{>}\tt{>}\tt{>}}$ $\underline{\tt{>}\tt{-}\tt{>}\tt{>}\tt{>}}\tt{>}\tt{>}\tt{>}$ :::