atcoder#ABC237D. [ABC237D] LR insertion
[ABC237D] LR insertion
Score : points
Problem Statement
There is a sequence that contains one , .
Additionally, you are given a string of length , , consisting of L
and R
.
For each in this order, the following will be done.
- If is
L
, insert to the immediate left of in . - If is
R
, insert to the immediate right of in .
Find the final contents of .
Constraints
- is an integer.
- is
L
orR
.
Input
Input is given from Standard Input in the following format:
Output
Print the final contents of , separated by spaces.
5
LRRLR
1 2 4 5 3 0
Initially, .
is L
, which makes it .
is R
, which makes it .
is R
, which makes it .
is L
, which makes it .
is R
, which makes it .
7
LLLLLLL
7 6 5 4 3 2 1 0