CF899F.Letters Removing
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Petya has a string of length n consisting of small and large English letters and digits.
He performs m operations. Each operation is described with two integers l and r and a character c: Petya removes from the string all characters c on positions between l and r, inclusive. It's obvious that the length of the string remains the same or decreases after each operation.
Find how the string will look like after Petya performs all m operations.
佩佳有一个长度为 n 的字符串,该字符串由小写和大写英文字母以及数字组成。
他执行 m 次操作。每次操作用两个整数 l 和 r 以及一个字符 c 描述:佩佳将字符串中位置在 l 到 r(含端点)之间所有等于 c 的字符全部删除。显然,每次操作后字符串的长度保持不变或减少。
请找出佩佳执行完全部 m 次操作后,字符串最终的样子。
输入格式
The first string contains two integers n and m (1 ≤ n, m ≤ 2·105) — the length of the string and the number of operations.
The second line contains the string of length n, consisting of small and large English letters and digits. Positions in the string are enumerated from 1.
Each of the next m lines contains two integers l and r (1 ≤ l ≤ r), followed by a character c, which is a small or large English letter or a digit. This line describes one operation. It is guaranteed that r doesn't exceed the length of the string s before current operation.
第一行包含两个整数 n 和 m(1≤n,m≤2⋅105)—— 分别表示字符串的长度和操作次数。
第二行包含一个长度为 n 的字符串,由小写和大写英文字母以及数字组成。字符串中位置编号从 1 开始。
接下来的 m 行,每行包含两个整数 l 和 r(1≤l≤r),后跟一个字符 c,该字符为小写或大写英文字母或数字。此行描述一次操作。保证在当前操作前,r 不超过字符串 s 的长度。
输出格式
Print the string Petya will obtain after performing all m operations. If the strings becomes empty after all operations, print an empty line.
输出 Petya 在执行完所有 m 个操作后得到的字符串。如果所有操作完成后字符串变为空,则输出一个空行。
输入输出样例
输入#1
4 2 abac 1 3 a 2 2 c
输出#1
b
输入#2
3 2 A0z 1 3 0 1 1 z
输出#2
Az
输入#3
10 4 agtFrgF4aF 2 5 g 4 9 F 1 5 4 1 7 a
输出#3
tFrg4
输入#4
9 5 aAAaBBccD 1 4 a 5 6 c 2 3 B 4 4 D 2 3 A
输出#4
AB
说明/提示
In the first example during the first operation both letters 'a' are removed, so the string becomes "bc". During the second operation the letter 'c' (on the second position) is removed, and the string becomes "b".
In the second example during the first operation Petya removes '0' from the second position. After that the string becomes "Az". During the second operations the string doesn't change.
在第一个例子中,第一次操作移除了两个字母 'a',因此字符串变为 "bc"。第二次操作移除了位于第二位的字母 'c',字符串变为 "b"。
在第二个例子中,第一次操作中 Petya 移除了第二位的字符 '0',之后字符串变为 "Az"。第二次操作中字符串不发生变化。
输入解题思路,AI测评打分。不知道怎么写?