AT_abc465_c [ABC465C] Reverse Permutation
Description
You are given an integer $ N $ and a string $ S $ of length $ N $ consisting of `o` and `x`.
There is an integer sequence $ A=(A_1,A_2,\ldots,A_N) $ of length $ N $ . Initially, $ A=(1,2,\ldots,N) $ .
Perform the following operation on $ A $ for $ k=1,2,\ldots,N $ in this order.
- If $ S_k= $ `o`, reverse the first $ k $ terms of $ A $ . Specifically, replace $ A $ with $ (A_k,A_{k-1},\ldots,A_1,A_{k+1},A_{k+2},\ldots,A_N) $ .
- If $ S_k= $ `x`, do nothing.
Find $ A $ after all the operations are completed.
Input Format
The input is given from Standard Input in the following format:
> $ N $
> $ S $
Output Format
Output the elements of $ A $ after all the operations are completed, separated by spaces.
Explanation/Hint
### Sample Explanation 1
$ A $ changes as follows with each operation:
- For $ k=1 $ : reverse the first $ 1 $ term of $ A $ . $ A $ becomes $ (1,2,3,4,5) $ .
- For $ k=2 $ : reverse the first $ 2 $ terms of $ A $ . $ A $ becomes $ (2,1,3,4,5) $ .
- For $ k=3 $ : do nothing.
- For $ k=4 $ : reverse the first $ 4 $ terms of $ A $ . $ A $ becomes $ (4,3,1,2,5) $ .
- For $ k=5 $ : reverse the first $ 5 $ terms of $ A $ . $ A $ becomes $ (5,2,1,3,4) $ .
After all the operations are completed, $ A $ is $ A=(5,2,1,3,4) $ .
### Constraints
- $ 2\le N\le 5\times 10^5 $
- $ N $ is an integer.
- $ S $ is a string of length $ N $ consisting of `o` and `x`.