Codevita 2017 Round-1 Problem-C

Published on
-
1 mins read
Authors
  • Name
    Twitter

Problem:

CodeVita 2017 Round 1 Problem -C

Download Problem

Solution:

/*
Author: Krishankant Ray
* CodeVita 2017 Round 1
*/
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int d,k=0;
string arr;
cin>>d;
cin>>arr;
int n=arr.length();
char R[n];
for(int f=0; f<n; )
{
R[f]=arr[k++];
f+=((2*d)-2);
}
for(int i=1; i<d-1;i++)
{
R[i]=arr[k++];
for(int j=i; j<n;)
{
j+=((2*d)-2-(2*i));
R[j]=arr[k++];
j+=((2*i));
if(j<n)
R[j]=arr[k++];
}
}
for(int l=d-1; l<n;l+=((2*d)-2))
{
R[l]=arr[k++];
}
for(int f=0; f<n;f++)
{
if(R[f]=='X')
break;
else
cout<<R[f];
}
return 0;
}