#abc237d. D - LR insertion
D - LR insertion
Score : points
问题描述
存在一个包含一个 的序列,记作 。
另外,你得到了一个长度为 的字符串 ,由字符 L
和 R
组成。
按照从 的顺序,依次执行以下操作:
- 若 为
L
,则在 中 的左侧立即插入数字 。 - 若 为
R
,则在 中 的右侧立即插入数字 。
请找出最终的序列 的内容。
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
5
LRRLR
Sample Output 1
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 .
Sample Input 2
7
LLLLLLL
Sample Output 2
7 6 5 4 3 2 1 0
update @ 2024/3/10 10:15:34