题目链接:
http://codeforces.com/problemset/problem/746/B
题解:
水题,我是直接暴力模拟做的这道题目的。
代码:
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define met(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3
typedef long long ll;
const int maxn=2000+10;
char s1[maxn], s2[maxn];
int main()
{
int n;
met(s1,'\0');
met(s2,'\0');
scanf("%d",&n);
scanf("%s",s1);
if(n%2==1)
{
for(int i=n-1,j=0,k=n-1;i>0;i-=2,j++,k--)
{
s2[k]=s1[i];
s2[j]=s1[i-1];
}
s2[(n/2)]=s1[0];
}
else
{
for(int i=n-1,j=0,k=n-1;i>1;i-=2,j++,k--)
{
s2[j]=s1[i-1];
s2[k]=s1[i];
}
s2[n/2-1]=s1[0];
s2[n/2]=s1[1];
}
printf("%s\n",s2);
}