#P1383. 高级打字机
高级打字机
Description
Sanae has bought the latest advanced typewriter. As you would expect, the latest model has a new feature: it supports undo.
Please design a program for this advanced typewriter that supports the following types of operations:
T x: Type operation, which appends a lowercase letter to the end of the text.U x: Undo operation, which undoes the last modification operations.Q x: Query operation, which asks for and outputs the -th letter of the current text. Note that the Query operation does not count as a modification operation.
Initially, the text can be regarded as an empty string.
Input Format
Line : an integer , the number of operations.
The next lines each contain one command. It is guaranteed that the input commands are valid.
Output Format
Output one letter per line, which is the answer to each Query operation.
7
T a
T b
T c
Q 2
U 2
T c
Q 2
b
c
Hint
For the first of the testdata, .
For the first of the testdata, it is guaranteed that an Undo operation will not undo an Undo operation.
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号