Decoding(B)

 avatar
jackoup
c_cpp
a year ago
577 B
4
Indexable
CodeForces
#include <iostream>
using namespace std;

void fio() {
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
}


int main() {
    fio();
    int n;cin>>n;
    string word;cin>>word;
    int index = 0;
    char arr[n];
    int mid = (n-1)/2, left = mid-1,right = mid+1;
    arr[mid] = word[index++];
    for(int i = 0;i<n;i++,index++) {
        int size = n-index;
        if(size %2 == 0)
            arr[left--] = word[index];
        else
            arr[right++] = word[index];
    }

    for(char x:arr){
        cout<<x;
    }
    return 0;
}
Editor is loading...
Leave a Comment