#abc237d. D - LR insertion

D - LR insertion

Score : 400400 points

问题描述

存在一个包含一个 00 的序列,记作 A=(0)A=(0)
另外,你得到了一个长度为 NN 的字符串 S=s1s2sNS=s_1s_2\ldots s_N,由字符 LR 组成。

按照从 i=1,2,,Ni=1, 2, \ldots, N 的顺序,依次执行以下操作:

  • sis_iL,则在 AAi1i-1 的左侧立即插入数字 ii
  • sis_iR,则在 AAi1i-1 的右侧立即插入数字 ii

请找出最终的序列 AA 的内容。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There is a sequence that contains one 00, A=(0)A=(0).
Additionally, you are given a string of length NN, S=s1s2sNS=s_1s_2\ldots s_N, consisting of L and R.

For each i=1,2,,Ni=1, 2, \ldots, N in this order, the following will be done.

  • If sis_i is L, insert ii to the immediate left of i1i-1 in AA.
  • If sis_i is R, insert ii to the immediate right of i1i-1 in AA.

Find the final contents of AA.

Constraints

  • 1N5×1051\leq N \leq 5\times 10^5
  • NN is an integer.
  • S=N|S| = N
  • sis_i is L or R.

Input

Input is given from Standard Input in the following format:

NN

SS

Output

Print the final contents of AA, separated by spaces.

Sample Input 1

5
LRRLR

Sample Output 1

1 2 4 5 3 0

Initially, A=(0)A=(0).
S1S_1 is L, which makes it A=(1,0)A=(1,0).
S2S_2 is R, which makes it A=(1,2,0)A=(1,2,0).
S3S_3 is R, which makes it A=(1,2,3,0)A=(1,2,3,0).
S4S_4 is L, which makes it A=(1,2,4,3,0)A=(1,2,4,3,0).
S5S_5 is R, which makes it A=(1,2,4,5,3,0)A=(1,2,4,5,3,0).

Sample Input 2

7
LLLLLLL

Sample Output 2

7 6 5 4 3 2 1 0

update @ 2024/3/10 10:15:34

}