시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
10 초 128 MB 83 15 13 20.968%

문제

그냥 단순히 문자열 조작 연산을 구현하는 문제이다. 문제 이름은 딱히 필요가 없어서 짓지 않았다.

입력

첫 줄에 테스트 케이스의 수 T가 주어진다. ( 1 ≤ T ≤ 100 )

각 테스트 케이스의 첫 줄엔 문자열 S가 주어진다. ( 1 ≤ |S| ≤ 1,000,000 )

이어서 한 줄 이상의 연산 내용이 주어진다. 문제에서 말하는 인덱스는 0부터 시작한다.

  • I R X : 문자열 S의 인덱스 X (0 ≤ X ≤ |S|) 에 문자열 R을 삽입한다. X=|S|인 경우엔 문자열 S의 뒤에 문자열 R을 이어붙인다. 예를 들어 문자열 S=abc일 때, I xy 1의 결과는 axybc, I xy 3의 결과는 abcxy, I xy 0의 결과는 xyabc가 된다.
  • P X Y : 문자열 S의 인덱스 X부터 Y까지의 문자를 출력한다. (0 ≤ X ≤ Y < |S|). 예를 들어 문자열 S=abc일 때, P 0 2의 출력은 abc, P 1 1의 출력은 b가 된다.
  • END : 테스트 케이스의 종료를 의미한다.
S와 R은 항상 알파벳 소문자로만 구성되어 있으며, 연산의 결과로 S의 길이가 100만을 넘어가는 경우는 없다. 또한, 출력되는 문자의 개수의 합은 모든 테스트 케이스에서 100만을 초과하지 않는다.
입력과 출력의 양이 방대하므로 빠른 입출력 함수 사용을 권장한다.

출력

P X Y 연산이 등장할 때마다 대응하는 부분 문자열을 출력한다.

예제 입력 1

1
acm
I ac 3
P 0 3
I x 3
I xxxx 6
I pc 6
P 0 11
END

예제 출력 1

acma
acmxacpcxxxx
W3sicHJvYmxlbV9pZCI6Ijk1NDgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJiMzRcdWM4MWMiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YWRmOFx1YjBlNSBcdWIyZThcdWMyMWNcdWQ3ODggXHViYjM4XHVjNzkwXHVjNWY0IFx1Yzg3MFx1Yzc5MSBcdWM1Zj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