Logo
(追記) (追記ここまで)

31590번 - Candy Compress 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB134866161.616%

문제

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 26ドル$ 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 1ドル$-indexed string of $n$ characters, which represents the colors of the initial candies. The string consists of only uppercase Latin characters (AZ). After loading the string, there are $q$ operations that you need to support. Each operation is either one of the following:

  • Operation 1: Insert the uppercase Latin character $c$ to the string so that the character is in the $i$-th position in the new string. In particular, $i = 1$ means inserting character $c$ at the beginning of the string. It is guaranteed that 1ドル ≤ i ≤ m + 1,ドル where $m$ is the length of the string just before this operation.
  • Operation 2: Remove the characters of the string from the $l$-th to the $r$-th position, inclusive. It is guaranteed that 1ドル ≤ l ≤ r ≤ m,ドル where $m$ 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 $l$-th position to the $r$-th position just before the operation.

입력

The first line of input contains two integers $n$ and $q$ (1ドル ≤ n ≤ 300,円 000$; 1ドル ≤ q ≤ 300,円 000$). The second line contains a string consisting of $n$ uppercase Latin characters representing the initial string to be loaded by the data structure. Each of the next $q$ lines represents an operation with either one of the following formats:

  1. 1 $c$ $i$ represents an Operation 1. It is guaranteed that $c$ is an uppercase Latin character and 1ドル ≤ i ≤ m + 1,ドル where $m$ is the length of the string just before this operation.
  2. 2 $l$ $r$ represents an Operation 2. It is guaranteed that 1ドル ≤ l ≤ r ≤ m$ where $m$ 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.

제한

예제 입력 1

3 5
XPA
1 P 3
1 P 5
2 2 5
1 Y 2
2 1 2

예제 출력 1

PPAP
XY

The first and second operations modify the string in the data structure as follows: XPAXPPAXPPAP. The third operation removes PPAP from the string, leaving the string X in the data structure. The fourth operation inserts the character Y to the end of the string. The last operation removes XY from the string, leaving an empty string in the data structure.

예제 입력 2

27 7
ICPCASIAPACIFICCHAMPIONSHIP
2 5 8
2 5 11
1 A 5
1 P 6
1 A 7
1 C 8
2 1 8

예제 출력 2

ASIA
PACIFIC
ICPCAPAC

힌트

출처

ICPC > Regionals > Asia Pacific > Asia Pacific Championship > The 2024 ICPC Asia Pacific Championship 연습 세션 PA번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /