#include <bits/stdc++.h>
using namespace std;
int main() {
int n,len,r;
string str;
cin>>n;
while(n!=0)
{
cin>>str;
len = str.length();
r = len/n;
char a[len][r];
int k=0;
for(int i=0;i<r;i++)
{
if(i%2==0)
{
for(int j=0;j<n;j++)
a[i][j] = str[k++];
}
else
{
for(int j=n-1;j>=0;j--)
a[i][j] = str[k++];
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<r;j++)
cout<<a[j][i];
}
cout<<endl;
cin>>n;
}
return 0;
}
the custom inputs are giving the correct results though
link to solution : https://www.codechef.com/viewsolution/28576122`Preformatted text`