CF525B.Pasha and String

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 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|.

You face the following task: determine what Pasha's string will look like after m days.

帕沙生日时收到了一个非常漂亮的字符串 ss,该字符串由小写拉丁字母组成。字符串中的字符从左到右编号为 11 到 ∣s∣|s|,其中 ∣s∣|s| 表示给定字符串的长度。

帕沙并不太喜欢这份礼物,于是决定对它进行修改。生日过后,帕沙花费了 mm 天对字符串执行如下变换——每天他选择一个整数 aia_i,并将字符串中从位置 aia_i 到位置 ∣s∣−ai+1|s| - a_i + 1 的子串(即一个区间)进行翻转。题目保证 2⋅ai≤∣s∣2 \cdot a_i \leq |s|。

你需要完成以下任务:确定经过 mm 天后帕沙的字符串将变成什么样子。

输入格式

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 a__i (1 ≤ a__i; 2·a__i ≤ |s|) — the position from which Pasha started transforming the string on the i-th day.

输入的第一行包含帕沙的字符串 ss,其长度为 22 到 2⋅1052\cdot10^5 个字符,由小写拉丁字母组成。

第二行包含一个整数 mm(1≤m≤1051\le m\le 10^5)—— 帕沙修改字符串的天数。

第三行包含 mm 个以空格分隔的整数 aia_i(1≤ai1\le a_i;2⋅ai≤∣s∣2\cdot a_i\le |s|)—— 表示第 ii 天帕沙开始变换字符串的位置。

输出格式

In the first line of the output print what Pasha's string s will look like after m days.

在输出的第一行打印帕沙的字符串 ss 经过 mm 天后的结果。

输入输出样例

  • 输入#1

    abcdef
    1
    2

    输出#1

    aedcbf
  • 输入#2

    vwxyz
    2
    2 2

    输出#2

    vwxyz
  • 输入#3

    abcdef
    3
    1 2 3

    输出#3

    fbdcea

输入解题思路,AI测评打分。不知道怎么写?

首页