525B.md (1614B)
1 Source: https://codeforces.com/problemset/problem/525/B 2 3 B. Pasha and String 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23 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 *a**i* and reversed a piece of string (a segment) from position *a**i* to position |*s*| - *a**i* + 1. It is guaranteed that 2·*a**i* ≤ |*s*|. 24 25 You face the following task: determine what Pasha's string will look like after *m* days. 26 27 Input 28 29 The first line of the input contains Pasha's string *s* of length from 2 to 2·105 characters, consisting of lowercase Latin letters. 30 31 The second line contains a single integer *m* (1 ≤ *m* ≤ 105) — the number of days when Pasha changed his string. 32 33 The third line contains *m* space-separated elements *a**i* (1 ≤ *a**i*; 2·*a**i* ≤ |*s*|) — the position from which Pasha started transforming the string on the *i*-th day. 34 35 Output 36 37 In the first line of the output print what Pasha's string *s* will look like after *m* days. 38 39 Examples 40 41 Input 42 43 ``` 44 abcdef 45 1 46 2 47 ``` 48 49 Output 50 51 ``` 52 aedcbf 53 ``` 54 55 Input 56 57 ``` 58 vwxyz 59 2 60 2 2 61 ``` 62 63 Output 64 65 ``` 66 vwxyz 67 ``` 68 69 Input 70 71 ``` 72 abcdef 73 3 74 1 2 3 75 ``` 76 77 Output 78 79 ``` 80 fbdcea 81 ```