#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 55.
  • The string starts with >\tt{>} and ends with >>>\tt{>}\tt{>}\tt{>}.
  • The rest of the string consists only of \tt{-}.

For example, >>>>\tt{>}\tt{-}\tt{-}\tt{>}\tt{>}\tt{>} and >>>>\tt{>}\tt{-}\tt{-}\tt{-}\tt{>}\tt{>}\tt{>} are valid arrow strings, while >>>\tt{>}\tt{-}\tt{>}\tt{>} and >>>>>\tt{>}\tt{-}\tt{>}\tt{-}\tt{>}\tt{>}\tt{>} are not.

Sauden gives you a string ss of length nn, consisting of >\tt{>} and \tt{-}. You need to create ss by performing a series of painting operations on a string of the same length nn that consists entirely of \tt{*}. In one painting operation, you can choose a substring of length at least 55 and transform it into an arrow string. The total number of operations you perform cannot exceed nn.

If it is impossible to obtain the string ss using no more than nn painting operations, output No\texttt{No}. Otherwise, output Yes\texttt{Yes} and provide the details of the painting operations. If there are multiple solutions, output any.

输入格式

The first line contains a single integer TT (1T1041\le T\le 10^4), indicating the number of test cases.

Each test case contains a string ss of length nn (5n1055 \le n \le 10^5) in a single line, consisting only of >\tt{>} and \tt{-}.

It is guaranteed that the sum of nn over all test cases does not exceed 51055 \cdot 10^5.

输出格式

For each test case, if the given string cannot be obtained by performing no more than nn painting operations, output No\texttt{No} in a single line. Otherwise, output Yes\texttt{Yes} and a positive integer mm (1mn1 \le m \le n), which denotes the number of painting operations to perform. Then output mm lines, each contains two integers pp (1pn41\le p\le n-4) and ll (5ln+1p5\le l\le n+1-p), 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{*}\tt{*}\tt{*}\tt{*}\tt{*}\tt{*}\tt{*}\tt{*} \rightarrow $\tt{*}\underline{\tt{>}\tt{-}\tt{-}\tt{-}\tt{>}\tt{>}\tt{>}}$ \rightarrow $\underline{\tt{>}\tt{-}\tt{>}\tt{>}\tt{>}}\tt{>}\tt{>}\tt{>}$ :::