/
Time Limit: 2 sec / Memory Limit: 1024 MiB
問題文
いくつかの英小文字とちょうど 2 つの X からなる文字列 S が与えられます。
次の操作を行なった後に得られる文字列を出力してください。
S のうち 2 つの
Xで挟まれた部分、すなわち 1 つめのXの直後の文字から 2 つめのXの直前までの文字からなる部分(これは空文字列の可能性もある)を反転させる。 その後、2 つのXを取り除き、残りの文字列を順番を変えることなく連結し 1 つの文字列とする。
ただし、文字列 T を反転させて得られる文字列 T' とは、T と同じ長さの文字列であって、 T' の i (1\leq i\leq \lvert T\rvert) 文字目が T の (\lvert T\rvert+1-i) 文字目と等しいようなものをさします。 ここで、\lvert T\rvert は文字列 T の長さを表します。
制約
- S は英小文字および
Xからなる長さ 3 以上 100 以下の文字列 - S は
Xをちょうど 2 つ含む。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S に対して操作を行なった後に得られる文字列を出力せよ。
入力例 1
stXnirXg
出力例 1
string
2 つの X に挟まれた文字列は nir です。
よって、この部分を反転させると stXrinXg となります。
その後、2 つの X を取り除き、残りの文字列を順番を保って連結すると、string となります。
入力例 2
samXXple
出力例 2
sample
空文字列を反転させたものは空文字列であることに注意してください。
入力例 3
XesreverX
出力例 3
reverse
Problem Statement
You are given a string S consisting of lowercase English letters and exactly two X's.
Apply the following operation and print the resulting string.
Reverse the part between the two
X's in S, namely the part starting from the character right after the firstXthrough the character right before the secondX, which may be empty. Then, remove the twoX's and concatenate the remaining strings without changing their order to form a single string.
The string T' obtained by reversing a string T is defined as the string whose length equals that of T, where the i-th (1\leq i\leq \lvert T\rvert) character of T' equals the (\lvert T\rvert+1-i)-th character of T. Here, \lvert T\rvert denotes the length of the string T.
Constraints
- S is a string of length between 3 and 100, inclusive, consisting of lowercase English letters and
X. Xoccurs exactly twice in S.
Input
The input is given from Standard Input in the following format:
S
Output
Print the resulting string after applying the operation against S.
Sample Input 1
stXnirXg
Sample Output 1
string
The substring between the two X's is nir;
reversing this part makes it stXrinXg.
After removing the two X's and concatenating the remaining strings preserving the order, it results in string.
Sample Input 2
samXXple
Sample Output 2
sample
Note that reversing an empty string makes it an empty string.
Sample Input 3
XesreverX
Sample Output 3
reverse