time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.

Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m days performing the following transformations on his string — each day he chose integer ai and reversed a piece of string (a segment) from position ai to position |s| - ai + 1. It is guaranteed that 2·ai ≤ |s|.

You face the following task: determine what Pasha's string will look like after m days.

Input

The first line of the input contains Pasha's string s of length from 2 to 2·105 characters, consisting of lowercase Latin letters.

The second line contains a single integer m (1 ≤ m ≤ 105) —  the number of days when Pasha changed his string.

The third line contains m space-separated elements ai (1 ≤ ai; 2·ai ≤ |s|) — the position from which Pasha started transforming the string on the i-th day.

Output

In the first line of the output print what Pasha's string s will look like after m days.

Sample test(s)
Input
abcdef
1
2
Output
aedcbf
Input
vwxyz
2
2 2
Output
vwxyz
Input
abcdef
3
1 2 3
Output
fbdcea

翻转的子串是中心对称的。
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
#include <iomanip>
using namespace std;
const int INF=0x4fffffff;
const int EXP=1e-;
const int MS=; char str[*MS];
int n;
int flag[MS]; int main()
{
scanf("%s",str);
scanf("%d",&n);
memset(flag,,sizeof(flag));
int len=strlen(str);
int x;
for(int i=;i<n;i++)
{
scanf("%d",&x);
flag[x-]++;
}
for(int i=;i<len/;i++)
flag[i]+=flag[i-];
for(int i=;i<len/;i++)
{
if(flag[i]%==)
continue;
else
{
char c=str[i];
str[i]=str[len--i];
str[len--i]=c;
}
}
printf("%s\n",str);
return ;
}

最新文章

  1. 【Android】Android如何一进入一个activity就弹出输入法键盘
  2. 详解Android定位
  3. 【POJ】3076 Sudoku
  4. java 集合框架图
  5. Lucene 08 - 什么是Lucene的相关度排序 + Java API调整相关度
  6. centos7下安装python3.6
  7. log4net:ERROR ConfigureFromXml called with null &#39;element&#39; parameter
  8. day23-python操作数据库三
  9. 33. 完全卸载oracle11g步骤
  10. Mockito学习(zz)
  11. 内存溢出导致jenkins自动部署到tomcat失败
  12. Servlet基础笔记
  13. mysql 导入 csv 格式数据
  14. rman中 Backup Set 与 Image Copy 优缺点比较
  15. Java中int与String间的类型转换
  16. Linux shell(. /path/filename)
  17. vmware实现物理机和虚拟机复制粘贴
  18. delphi xe7 多线程调用CMD,使用管道,临界区技术,实现指定用户名,多线程,异步返回CMD命令结果到memo
  19. python--内置常用模块
  20. SQL Server调试存储过程

热门文章

  1. 第三百五十五天 how can I 坚持
  2. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
  3. c# spring aop的简单例子
  4. GWT+CodeTemplate+TableCreate快速开发
  5. MFC如何添加系统消息处理函数?
  6. 遇见了这个问题:App.config提示错误“配置系统未能初始化”
  7. rome实现rss订阅与发布
  8. D. Green and Black Tea
  9. Flex 拾色器改变背景
  10. 【AS3 Coder】任务七:初涉PureMVC——天气预报功能实现