B. Pasha and String
Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx Solved: 2xx题目连接
http://codeforces.com/contest/525/problem/B
Description
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
Sample Input
abcdef 1 2
vwxyz 2 2 2
abcdef 3 1 2 3
Sample Output
aedcbf
vwxyz
fbdcea
HINT
题意:
给你一个字符串,然后给你一个数字i,然后i到s.size()-i直接的位置全部翻转,然后问你m次操作之后,是什么样子
题解:
首先,只有翻转奇数次和翻转偶数次两种情况,我们用一个类似前缀和的操作,就可以处理出这个位置究竟翻转了多少次,然后输出就好啦
~\(≧▽≦)/~啦啦啦,这道题完啦
代码:
//qscqesze#include#include #include #include #include #include #include #include #include #include #include #include #include