time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word’s length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.

Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.

You are given an encoding s of some word, your task is to decode it.

Input

The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.

The second line contains the string s of length n consisting of lowercase English letters — the encoding.

Output

Print the word that Polycarp encoded.

Examples

input

5

logva

output

volga

input

2

no

output

no

input

4

abba

output

baba

Note

In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.

In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.

In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.

【题目链接】:http://codeforces.com/contest/746/problem/B

【题解】



一开始以为是顺着来;

结果发现是要你倒推出原来的字符串是啥。

模拟一下就好;

奇数的话是/2 + 1

偶数位置就是/2



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; //const int MAXN = x;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); int n;
string s; int main()
{
//freopen("F:\\rush.txt","r",stdin);
cin >> n;
cin >> s;
reverse(s.begin(),s.end());
int len = s.size();
s = ' '+s;
string ans = " ";
int now = 0;
rep1(i,1,len)
{
if (now == 0)
ans+=s[i],now++;
else
{
int tnow = now+1,po;
if (tnow&1)
{
po = (tnow/2) + 1;
string temp ="";
temp += s[i];
ans.insert(po,temp);
}
else
{
po= (tnow/2);
string temp ="";
temp += s[i];
ans.insert(po,temp);
}
now++;
}
}
ans.erase(0,1);
cout << ans << endl;
return 0;
}

【75.28%】【codeforces 764B】Decoding的更多相关文章

  1. 【codeforces 764B】Timofey and cubes

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  3. 【codeforces 757D】Felicity's Big Secret Revealed

    [题目链接]:http://codeforces.com/problemset/problem/757/D [题意] 给你一个01串; 让你分割这个01串; 要求2切..n+1切; 对于每一种切法 所 ...

  4. 【30.93%】【codeforces 558E】A Simple Task

    time limit per test5 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...

  5. 【77.78%】【codeforces 625C】K-special Tables

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  6. 【codeforces 760A】Petr and a calendar

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  8. 【搜索】【并查集】Codeforces 691D Swaps in Permutation

    题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...

  9. 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

随机推荐

  1. jQuery动态加载动画spin.js

    在线演示 本地下载

  2. SDUT-3373_数据结构实验之查找一:二叉排序树

    数据结构实验之查找一:二叉排序树 Time Limit: 400 ms Memory Limit: 65536 KiB Problem Description 对应给定的一个序列可以唯一确定一棵二叉排 ...

  3. Java练习 SDUT-2271_Eddy的难题

    Eddy的难题 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 人随着岁数的增长是越大越聪明还是越大越笨,这是一个值得全 ...

  4. Servlet Cookies

    Cookie是在多个客户端请求之间持久存储的一小段信息. Cookie具有名称,单个值和可选属性,例如注释,路径和域限定符,生存周期和版本号. Cookie工作原理 默认情况下,每个请求都被视为新的请 ...

  5. IDEA入门(1)--lombok和Junit generator2插件的运用

    前言 最近在慕课网看到了一些视频,准备从0开始做一个电商网站.视频中的大牛用的java的IDE都是IDEA,让我很纠结.从as到MyEclipse,好不容易稍微熟悉了一下MyEclipse的基本操作, ...

  6. 使用spring jpa 时,利用nativeQuery,获取数据,无需新建实体,按照别名返回Json数据

    刚开始是这样写的 @Query(value = "SELECT ll.user_id id ,u.catong_img catong_img,ll.locationId location_i ...

  7. iOS 设计 用户为王 - 关于征询授权、注册及加载等待的体验优化

    你要做的东西一定要是你无比渴望这世界上能出现的东西,这股热情和能量将会融入到你的应用中,成为它腾飞的初速度,为你带来积极反馈.把自己当做app最重要的用户,这一点非常重要. http://www.co ...

  8. 14.libgdx的一些坑记录(持续更新)

    1. internal的文件路径 无法用list获取目录下文件     2.动态打包散图无法放入资源管理器,只能在资源加载器打包后的散图再合成打包,但都不如提前打包 3.资源加载器读入以texture ...

  9. Facebook F8|闲鱼高级技术专家参会分享

    笔者代表闲鱼参加了Facebook在4月30日举行的为期二天的F8大会,地点加州.将会议概括和一些收获分享给大家.对国内开发者而言,Facebook的产品设计.社区.VR/AR等有一些借鉴意义:对海外 ...

  10. Python 进阶02 文本文件的输入输出

    Python 具有基本的文本文件读写功能,Python的标准库提供有更丰富的读写功能. 文本文件的读写主要通过open()所构建的文件对象来实现 创建文件对象 我们打开一个文件,并适用一个对象来表示该 ...