102373: [AtCoder]ABC237 D - LR insertion

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

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

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

  • If $s_i$ is L, insert $i$ to the immediate left of $i-1$ in $A$.
  • If $s_i$ is R, insert $i$ to the immediate right of $i-1$ in $A$.

Find the final contents of $A$.

Constraints

  • $1\leq N \leq 5\times 10^5$
  • $N$ is an integer.
  • $|S| = N$
  • $s_i$ is L or R.

Input

Input is given from Standard Input in the following format:

$N$
$S$

Output

Print the final contents of $A$, separated by spaces.


Sample Input 1

5
LRRLR

Sample Output 1

1 2 4 5 3 0

Initially, $A=(0)$.
$S_1$ is L, which makes it $A=(1,0)$.
$S_2$ is R, which makes it $A=(1,2,0)$.
$S_3$ is R, which makes it $A=(1,2,3,0)$.
$S_4$ is L, which makes it $A=(1,2,4,3,0)$.
$S_5$ is R, which makes it $A=(1,2,4,5,3,0)$.


Sample Input 2

7
LLLLLLL

Sample Output 2

7 6 5 4 3 2 1 0

Input

题意翻译

给一个只有 $ 1 $ 个 $ 0 $ 的数列 $ A=(0) $。 另外,给一个长度为 $ N $ 的仅由 $ L $ 和 $ R $ 构成的字符串 $ S $。 - 当 $ Si $ 为 $ L $ 时,将 $ i $ 插入 $ A $ 中 $ i-1 $ 的左侧。 - 当 $ Si $ 为 $ R $ 时,将 $ i $ 插入 $ A $ 中 $ i-1 $ 的右侧。 求最终的 $ A $ 数列。

Output

分数:400分 部分 问题描述 有一个包含一个0的序列,A=(0)。 此外,你将得到一个由L和R组成的长度为N的字符串S=s1s2...sN。 按照以下顺序,对每个i=1,2,...,N执行以下操作。 * 如果$s_i$是L,在$A$中在第i-1个元素的左边插入i。 * 如果$s_i$是R,在$A$中在第i-1个元素的右边插入i。 找出$A$的最终内容。 部分 约束 * $1≤N≤5×10^5$ * N是一个整数。 * $|S|=N$ * $s_i$是L或R。 输入输出格式 输入格式 从标准输入按以下格式获取输入: $N$ $S$ 输出格式 以空格分隔的方式打印$A$的最终内容。 样例输入 1 5 LRRLR 样例输出 1 1 2 4 5 3 0 最初,$A=(0)$。 $S_1$是L,使其变为$A=(1,0)$。 $S_2$是R,使其变为$A=(1,2,0)$。 $S_3$是R,使其变为$A=(1,2,3,0)$。 $S_4$是L,使其变为$A=(1,2,4,3,0)$。 $S_5$是R,使其变为$A=(1,2,4,5,3,0)$。 样例输入 2 7 LLLLLLL 样例输出 2 7 6 5 4 3 2 1 0

加入题单

算法标签: