시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 256 MB | 116 | 36 | 33 | 36.667% |
A long, long time ago, DOS3.x programmers were starting to get tired of EDLIN. So they gradually switched to editors that they wrote themselves.
Many years later, Alex has accidentally stumbled upon a text editor from back in these days. After some basic testing, he has made a shocking discovery: this software is able to perform tens of thousands of edit operations per second (of course, you cannot conduct these tests by hand)! So, Alex is spending sleepless nights trying to create a product like this himself. Can you help him?
To clarify the objective, Alex has created some definitions to make the term "text editor" less abstract:
Operation | Input Format | Function |
---|---|---|
Move(k) | Move k |
Moves the cursor's position to immediately after the k-th character in the text. If k= 0, then the cursor is moved to the start of the text. |
Insert(n, s) | Insert n↵ s |
Inserts a string s of length n (n ≥ 1) at the position of the cursor. The position of the cursor does not change. |
Delete(n) | Delete n |
Delete the n (n ≥ 1) characters following the cursor. The position of the cursor does not change. |
Get(n) | Get n |
Outputs the n (n ≥ 1) characters following the cursor. The position of the cursor does not change. |
Prev | Prev |
Moves the cursor backwards by one character. |
Next | Next |
Moves the cursor forwards by one character. |
For example, an empty text editor when given the operations: Insert(13, "Balanced tree
"), Move(2), Delete(5), Next(), Insert(7, "editor
"), Move(0), and Get(16), will output "Bad editor tree
".
Your task is to:
The first line of input contains an integer t, the number of operations. The following lines contain t operations. To make text from the text editor easier to read, the string following the Insert() operation may contain multiple line breaks. You must ignore them (if this is hard to understand, please refer to the sample input and output below). Other than new line characters, all of the characters in the input will have ASCII values within the range [32, 126], inclusive. There will be no trailing spaces.
You can assume that for each test case:
Each line of the output should contain the text outputted by a single corresponding Get() operation.
15 Insert 26 abcdefghijklmnop qrstuv wxy Move 16 Delete 11 Move 5 Insert 1 ^ Next Insert 1 _ Next Next Insert 4 .\/. Get 4 Prev Insert 1 ^ Move 0 Get 22
.\/. abcde^_^f.\/.ghijklmno