CodeforcesJul 07, 2025

Repeating Cipher

Hazrat Ali

Codeforces

Repeating cipher is used for strings. To encrypt the string s=s1s2sms=s1s2…sm (1m10), Polycarp uses the following algorithm:

  • he writes down s1 ones,
  • he writes down s2 twice,
  • he writes down s3 three times
  • he writes down smsm mm times.

For example, if s="bab" the process is: "b "baa "baabbb". So the encrypted s="bab" is "baabbb".

Given string t  the result of encryption of some string s. Your task is to decrypt it, i. e. find the string s.

Input

The first line contains integer nn (1n55) — the length of the encrypted string. The second line of the input contains t — the result of encryption of some string ss. It contains only lowercase Latin letters. The length of tt is exactly nn.

It is guaranteed that the answer to the test exists.

Output

Print such string ss that after encryption it equals tt.

Examples
Input
6
baabbb
Output
bab
Input
10
ooopppssss
Output
oops
Input
1
z
Output
z


Solution
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans;
  int temp = 0;
  for (int i = 0; i < n; i += temp) {
    ans += s[i];
    temp++;
  }
  cout << ans << endl;
  return 0;
}



Comments