#P4807. Pasha and String
Pasha and String
Pasha and String
题面翻译
给定一个字符串s,对其进行m次操作,第i次操作给一个数字,表示将字符串s的第x个位置到第len-x+1这段字翻转,求m次操作后的结果。
题目描述
Pasha got a very beautiful string for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to from left to right, where 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 days performing the following transformations on his string — each day he chose integer and reversed a piece of string (a segment) from position to position . It is guaranteed that .
You face the following task: determine what Pasha's string will look like after days.
输入格式
The first line of the input contains Pasha's string of length from to characters, consisting of lowercase Latin letters.
The second line contains a single integer ( ) — the number of days when Pasha changed his string.
The third line contains space-separated elements ( ; ) — the position from which Pasha started transforming the string on the -th day.
输出格式
In the first line of the output print what Pasha's string will look like after days.
样例 #1
样例输入 #1
abcdef
1
2
样例输出 #1
aedcbf
样例 #2
样例输入 #2
vwxyz
2
2 2
样例输出 #2
vwxyz
样例 #3
样例输入 #3
abcdef
3
1 2 3
样例输出 #3
fbdcea