No.3779 L or R
タグ : / 解いたユーザー数 46
作問者 :
Problem Statement
$N$ lamps are arranged in a horizontal row. For $1\le i\le N$, the $i$-th lamp from the left is called lamp $i$. Each lamp has $2$ states: the off state and the on state. Each lamp also has a button, and every press of the button switches the state of that lamp.
The initial states of the lamps are given as a string $S$. $S$ is a string of length $N$ consisting of o and x.
If the $i$-th character of $S$ is o, lamp $i$ is initially on;
if it is x, lamp $i$ is initially off.
You will now perform $N$ operations. In the $i$-th operation $(1\le i\le N)$, choose exactly one of the following $2$ types of operations and perform it.
-
Operation $L$
For $j=1,2,\cdots ,i$, press the button of lamp $j$ $1$ time each.
-
Operation $R$
For $j=i,i+1,\cdots ,N$, press the button of lamp $j$ $1$ time each.
Note that the button of lamp $i$ is always pressed, whichever operation you choose.
Determine whether it is possible, by performing the $N$ operations appropriately, to have all lamps on after all operations are finished. If it is possible, output $1$ such sequence of operations.
Constraints
- $1\le N\le 2\times 10^5$
- $S$ is a string of length $N$ consisting of
oandx - $N$ is an integer
Input
The input is given in the following format.
$N$ $S$
Output
If no sequence of operations satisfying the condition in the problem statement exists, output No on one line.
If one exists, output Yes on line $1$, and output a string $T$ representing the sequence of operations on line $2$.
Here, $T$ is a string of length $N$ consisting of L and R. If the $i$-th character of $T$ is L, operation $L$ is performed in the $i$-th operation;
if it is R, operation $R$ is performed in the $i$-th operation.
Print a newline at the end.
Sample
Sample 1
Input
4 oxox
Output
Yes LLLL
Through the $4$ operations, the states of the lamps change as oxox $\rightarrow$ xxox $\rightarrow$ ooox $\rightarrow$ xxxx $\rightarrow$ oooo.
Sample 2
Input
1 o
Output
No
Sample 3
Input
10 ooxxxoxoxo
Output
Yes LRRLRRRRRR
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。