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 ;
}

B. Pasha and String的更多相关文章

  1. Pasha and String(思维,技巧)

    Pasha and String Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u S ...

  2. Codeforces Round #297 (Div. 2)B. Pasha and String 前缀和

    Codeforces Round #297 (Div. 2)B. Pasha and String Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx ...

  3. 字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String

    题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的 ...

  4. codeforces B. Pasha and String

    Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters ...

  5. [ An Ac a Day ^_^ ] CodeForces 525B Pasha and String 技巧

    题意就是一次次翻转字符串 然后输出最终的字符串 暴力一发O(n*m)果然超时了 因为每次翻转的的都是a-1到对称位置 所以一个位置翻转两次等于没有操作 所以只需要记录一下len/2的位置前的操作次数 ...

  6. codeforces B. Pasha and String(贪心)

    题意:给定一个长度为len的字符序列,然后是n个整数,对于每一个整数ai, 将字符序列区间为[ai,len-ai+1]进行反转.求出经过n次反转之后的序列! /* 思路1:将区间为偶数次的直接去掉!对 ...

  7. codeforces525B

    Pasha and String CodeForces - 525B Pasha got a very beautiful string s for his birthday, the string ...

  8. cf- 297 < b > -- 区间翻转操作的优化

    B. Pasha and String time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. Pasha and Phone(思维)

    Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

随机推荐

  1. 统一入口的Ajax验证

    此前一直没有写博客的习惯,只是将一些心得和体会大致的用笔写在一个本子上,今天刚刚开通博客,就随便写一点吧! 关于服务端验证,大致可以分为登陆验证与功能权限验证,而以前端请求方式来区分的话,又可分为 1 ...

  2. delphi 集合

    DELPHI没有JAVA的丰富的集合(SET MAP LIST),只有Tlist,可包装各种类型

  3. Clean Code第二章<命名>

    1.命名要有意义 错误写法 正确写法 2.某些构造函数可以提供有意义的静态方法去实现

  4. compiled python files

    [compiled python files] As an important speed-up of the start-up time for short programs that use a ...

  5. 理解js闭包(一)

    @(编程) 闭包(closure)是Javascript语言的一个难点,也是它的特色,很多高级应用都要依靠闭包实现. 一.变量的作用域 要理解闭包,首先必须理解Javascript特殊的变量作用域. ...

  6. GWT+CodeTemplate+TableCreate快速开发

    刚进一家新公司,公司表示让我们几个新人写页面联系熟悉 怎么快速开发,进入正题: 1.根据设计规范设计页面excel 2.CodeTemplate根据excel生成属性类和对应方法(文本框,下拉框等等单 ...

  7. 关于iTunes11.1 不能刷自制固件的解决方案

    由于iTunes升级到11.1后, 苹果在程序里限制了不允许刷自制固件, 所以想刷自制固件暂时只能降级iTunes到11.1版本之前, 这里提供iTunes 11.0.5 的下载地址: Windows ...

  8. Linux应用总结:自动删除n天前日志

    linux是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,让系统定时清理一些不需要的文件很有一种爽快的事情.不用你去每天惦记着是否需要清理日志 ...

  9. C++视频课程小结(2)

    C++远征之离港篇 章节介绍: 每章小结: 第一章:大致讲了一下本章会讲的内容:引用vs指针.const vs #define(这个我在C里都没用过).函数变得更强大.内存管理要小心之类的. 第二章: ...

  10. 10个经典的Java main 方法面试题

    1. 不用main方法如何定义一个类? 不行,没有main方法不能运行Java类. 在Java 7之前,你可以通过使用静态初始化运行Java类.但是,从Java 7 开始就不行了. 2. main() ...