Score : $400$ points
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.
L
, insert $i$ to the immediate left of $i-1$ in $A$.R
, insert $i$ to the immediate right of $i-1$ in $A$.Find the final contents of $A$.
L
or R
.Input is given from Standard Input in the following format:
$N$ $S$
Print the final contents of $A$, separated by spaces.
5 LRRLR
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)$.
7 LLLLLLL
7 6 5 4 3 2 1 0