Codeforces Round 990 (Div. 1)
F1
Yandex Cuneiform (Easy Version)
Codeforces
3300
原题
← E2F2 →
翻译中…

This is the easy version of the problem. The difference between the versions is that in this version, there are no question marks. You can hack only if you solved all versions of this problem.

翻译中…

For a long time, no one could decipher Sumerian cuneiform. However, it has finally succumbed to pressure! Today, you have the chance to decipher Yandex cuneiform.

翻译中…

Yandex cuneiform is defined by the following rules:

翻译中…
  1. An empty string is a Yandex cuneiform.
  2. If you insert exactly one copy of each of the three letters 'Y', 'D', and 'X' into a Yandex cuneiform in such a way that no two adjacent letters become equal after the operation, you obtain a Yandex cuneiform.
  3. If a string can't be obtained using the above rules, it is not a Yandex cuneiform.
翻译中…

You are given a template. A template is a string consisting of the characters 'Y', 'D', 'X', and '?'.

翻译中…

You need to check whether there exists a way to replace each question mark with 'Y', 'D', or 'X' to obtain a Yandex cuneiform, and if it exists, output any of the matching options, as well as a sequence of insertion operations to obtain the resulting cuneiform.

翻译中…

In this version of the problem, there are no question marks in the template.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 5 \cdot 10^4$). The description of the test cases follows.

翻译中…

Each test case consists of a single line containing a template of length $n$ ($3 \leq n \lt 2 \cdot 10^5$, $n \bmod 3 = 0$), consisting only of characters 'Y', 'D', 'X'.

翻译中…

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

翻译中…

Output

翻译中…

For each test case, output a single line containing 'NO' if it is not possible to obtain a cuneiform from the given template.

翻译中…

Otherwise, output 'YES' on the first line, and on the second line, any obtainable cuneiform. After that, you need to output the sequence of operations that leads to the cuneiform you printed.

翻译中…

A sequence of operations is described by $\frac{n}{3}$ triples of pairs. A pair has the form c p, where $c$ is one of the letters 'Y', 'D', or 'X', and $p$ is the position at which the letter $c$ should be inserted. The insertion position is the number of letters to skip from the beginning of the string for the insertion. For example, after inserting the character 'D' into the string "YDX" with $p=3$, the result is "YDXD", and with $p=0$, it is "DYDX". Note that the index cannot exceed the current length of the string.

翻译中…

The operations are applied from top to bottom, left to right. After inserting each triple to the string, there should be no two adjacent identical characters.

翻译中…

Note

翻译中…

In the second example, the string is transformed like this: $"" \to \mathtt{YDX} \to \mathtt{YDXDYX}$.

翻译中…

样例

Input #1
4
YDX
YDXDYX
YDX
DYYDXYXYX
Output #1
YES
YDX
X 0 D 0 Y 0
YES
YDXDYX
X 0 Y 0 D 1
X 2 D 3 Y 4
YES
YDX
Y 0 D 1 X 2
NO
InputCopy OutputCopy
题目信息
题号
2046F1
时间限制
2 s
内存限制
256 MB
标签
构造
数据结构
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。