atcoder#ZONE2021D. 宇宙人からのメッセージ
宇宙人からのメッセージ
Score : points
Problem Statement
You are given a ciphertext . It can be decrypted by the following procedure:
- Let be an empty string.
- For each in this order, do the following: ( denotes the length of )- if the -th character of is
R
, reverse ;- if the -th character of is not
R
, add that character to the end of .
- if the -th character of is not
- if the -th character of is
R
, reverse ; - if the -th character of is not
R
, add that character to the end of . - After the operation above, if there are two consecutive same characters in , remove those two characters. Repeat this operation as long as it can be done. (We can prove that the final string obtained does not depend on the order the characters are removed.)
Print the string obtained by this procedure.
Constraints
- consists of lowercase English letters and
R
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
ozRnonnoe
zone
We can decrypt it as follows:
- Initially, is an empty string.
- Add
o
at the end of , making ito
. - Add
z
at the end of , making itoz
. - Reverse , making it
zo
. - Add
n
at the end of , making itzon
. - Add
o
at the end of , making itzono
. - Add
n
at the end of , making itzonon
. - Add
n
at the end of , making itzononn
. - Add
o
at the end of , making itzononno
. - Add
e
at the end of , making itzononnoe
. - Delete two consecutive
n
s from , making itzonooe
. - Delete two consecutive
o
s from , making itzone
.
hellospaceRhellospace
The answer may be an empty string.