Candy Compress
시간 제한2초메모리 제한1024 MB
문자열에 삽입과 구간 삭제가 번갈아 일어날 때 각 삭제 연산에서 지워지는 문자들을 출력한다.
문제
You are developing a mobile game called Candy Compress. In this game, there are several colored candies lined up from left to right. There are possible colors. At any point in time, the player can choose to add a candy at any position or to remove a subset of neighboring candies to get points depending on the colors of the removed candies.
To develop the game, you need to implement the following data structure. Initially, the data structure loads a -indexed string of characters, which represents the colors of the initial candies. The string consists of only uppercase Latin characters (A–Z). After loading the string, there are operations that you need to support. Each operation is either one of the following:
- Operation 1: Insert the uppercase Latin character to the string so that the character is in the -th position in the new string. In particular, means inserting character at the beginning of the string. It is guaranteed that , where is the length of the string just before this operation.
- Operation 2: Remove the characters of the string from the -th to the -th position, inclusive. It is guaranteed that , where is the length of the string just before this operation.
For each Operation 2, your data structure needs to determine the characters that are removed, so that the game can calculate the number of points to be given to the player. In other words, you need to determine the content of the string from the -th position to the -th position just before the operation.
입력
The first line of input contains two integers and (; ). The second line contains a string consisting of uppercase Latin characters representing the initial string to be loaded by the data structure. Each of the next lines represents an operation with either one of the following formats:
1represents an Operation 1. It is guaranteed that is an uppercase Latin character and , where is the length of the string just before this operation.2represents an Operation 2. It is guaranteed that where is the length of the string just before this operation.
The operations are given in the order they are to be performed. It is guaranteed that there is at least one Operation 2.
출력
For each Operation 2 in order, output one line containing the characters that are removed by the operation.