Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 100 点
問題文
英小文字からなる長さが偶数の文字列 S が与えられます。S の長さを |S|、S の i 文字目を S_i で表します。
i = 1, 2, \ldots, \frac{|S|}{2} の順に以下の操作を行い、すべての操作を終えた後の S を出力してください。
- S_{2i-1} と S_{2i} を入れ替える
制約
- S は英小文字からなる長さが偶数の文字列
- S の長さは 100 以下
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
abcdef
出力例 1
badcfe
操作を行う前は S = abcdef
です。
i = 1 について操作を行うと、S_1 と S_2 が入れ替わるので S = bacdef
になります。
i = 2 について操作を行うと、S_3 と S_4 が入れ替わるので S = badcef
になります。
i = 3 について操作を行うと、S_5 と S_6 が入れ替わるので S = badcfe
になります。
したがって、badcfe
を出力します。
入力例 2
aaaa
出力例 2
aaaa
入力例 3
atcoderbeginnercontest
出力例 3
taocedbrgeniencrnoetts
Score : 100 points
Problem Statement
You are given a string S of even length consisting of lowercase English letters. Let |S| be the length of S, and S_i be the i-th character of S.
Perform the following operation for each i = 1, 2, \ldots, \frac{|S|}{2} in this order, and print the final S.
- Swap S_{2i-1} and S_{2i}.
Constraints
- S is a string of even length consisting of lowercase English letters.
- The length of S is at most 100.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
abcdef
Sample Output 1
badcfe
Initially, S = abcdef
.
Performing the operation for i = 1 swaps S_1 and S_2, making S = bacdef
.
Performing the operation for i = 2 swaps S_3 and S_4, making S = badcef
.
Performing the operation for i = 3 swaps S_5 and S_6, making S = badcfe
.
Thus, badcfe
should be printed.
Sample Input 2
aaaa
Sample Output 2
aaaa
Sample Input 3
atcoderbeginnercontest
Sample Output 3
taocedbrgeniencrnoetts