問題一覧 > 通常問題

No.3779 L or R

レベル : / AI推定難易度 : 1000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 46
作問者 : askr58 / テスター : 👑 AngrySadEight
お気に入りにしたユーザー ProblemId : 13411 / 自分の提出
問題文最終更新日: 2026-09-21 05:55:41
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 520 (順位表) の他の問題:

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 o and x
  • $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もしくは右上の雲マークをクリックしてアカウントを作成してください。