B. Pasha and String(Codeforces Round #297 (Div. 2) 水题)

B. Pasha and String

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Pasha got a very beautiful stringsfor 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 spentmdays performing the following transformations on his string—each day he chose integeraiandreverseda piece of string (a segment) from positionaito position|s|-ai+1. It is guaranteed that2·ai≤|s|.

You face the following task: determine what Pasha’s string will look like aftermdays.

Input

The first line of the input contains Pasha’s stringsof length from2to2·105characters, consisting of lowercase Latin letters.

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

The third line containsmspace-separated elementsai(1≤ai;2·ai≤|s|)—the position from which Pasha started transforming the string on thei-th day.

Output

In the first line of the output print what Pasha’s stringswill look like aftermdays.

Sample test(s)

input

abcdef12

output

aedcbf

input

vwxyz22 2

output

vwxyz

input

abcdef31 2 3

output

fbdcea

思路:因为按照题意所有的翻转都是按照中心对称翻,也就是说可以把翻转的次数记录下来,如果能被2整除就说明通过翻转他又回到了原来的地方,如果不能被整除就翻转一次。最后输出字符串。

scanfmemset{scanfa}{astrstr}}printf}}

,再长的路,一步步也能走完,再短的路,不迈开双脚也无法到达。

B. Pasha and String(Codeforces Round #297 (Div. 2) 水题)

相关文章:

你感兴趣的文章:

标签云: