CF159C.String Manipulation 1.0
普及/提高-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name s, a user can pick number p and character c and delete the p-th occurrence of character c from the name. After the user changed his name, he can't undo the change.
For example, one can change name "arca" by removing the second occurrence of character "a" to get "arc".
Polycarpus learned that some user initially registered under nickname t, where t is a concatenation of k copies of string s. Also, Polycarpus knows the sequence of this user's name changes. Help Polycarpus figure out the user's final name.
某个知名网站设计了一种独特的用户名编辑机制:用户只能通过删除用户名中的某些字符来修改用户名。具体而言,若当前用户名为 s,用户可选定一个数字 p 和一个字符 c,然后删除 s 中第 p 个出现的字符 c。一旦用户名被修改,该操作便不可撤销。
例如,用户名 “arca” 可通过删除第二个出现的字符 “a” 变为 “arc”。
波利卡普斯得知,某用户最初注册时的昵称为 t,其中 t 是由 k 个字符串 s 拼接而成(即 t=k 个 ss+s+⋯+s)。此外,波利卡普斯还掌握了该用户后续一系列的用户名修改操作。请帮助波利卡普斯计算出该用户的最终用户名。
输入格式
The first line contains an integer k (1 ≤ k ≤ 2000). The second line contains a non-empty string s, consisting of lowercase Latin letters, at most 100 characters long. The third line contains an integer n (0 ≤ n ≤ 20000) — the number of username changes. Each of the next n lines contains the actual changes, one per line. The changes are written as "p__i c__i" (without the quotes), where p__i (1 ≤ p__i ≤ 200000) is the number of occurrences of letter c__i, c__i is a lowercase Latin letter. It is guaranteed that the operations are correct, that is, the letter to be deleted always exists, and after all operations not all letters are deleted from the name. The letters' occurrences are numbered starting from 1.
第一行包含一个整数 k(1≤k≤2000)。
第二行包含一个非空字符串 s,由小写拉丁字母组成,长度至多为 100。
第三行包含一个整数 n(0≤n≤20000)—— 表示用户名修改操作的次数。
接下来的 n 行每行描述一次实际的修改操作。每次操作格式为 “pi ci”(不含引号),其中 pi(1≤pi≤200000)表示要删除的字母 ci 的第 pi 次出现(即按从左到右顺序计数的第 pi 个该字母),ci 是一个小写拉丁字母。
保证所有操作均合法,即:待删除的字母一定存在;且在所有操作完成后,用户名中并非所有字母都被删除。
字母的出现位置编号从 1 开始。
输出格式
Print a single string — the user's final name after all changes are applied to it.
输出一个字符串——应用所有更改后用户的最终姓名。
输入输出样例
输入#1
2 bac 3 2 a 1 b 2 c
输出#1
acb
输入#2
1 abacaba 4 1 a 1 a 1 c 2 b
输出#2
baa
说明/提示
Let's consider the first sample. Initially we have name "bacbac"; the first operation transforms it into "bacbc", the second one — to "acbc", and finally, the third one transforms it into "acb".
我们来考虑第一个样例。初始时,我们有字符串 “bacbac”;第一次操作将其变为 “bacbc”,第二次操作变为 “acbc”,最后,第三次操作将其变为 “acb”。
输入解题思路,AI测评打分。不知道怎么写?