| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12602 | OuQ String |
|
| 12669 | Another Text Editor |
|
Description
Define the level 1 string s1 = “OuQ”,
and the level k string sk = “O” + sk−1 + “u” + sk−1 + “Q”.
For example:
- s2 = “O” + s1 + “u” + s1 + “Q” = “OOuQuOuQQ”
- s3 = “OOOuQuOuQQuOOuQuOuQQQ”
Given 3 integeres k,l,r.
Please find all characters of sk[l],sk[l+1],...sk[r−1],sk[r]
Input
There’re multiple testcases in input.
Three integers k,l,r on each line.
- 1 ≤ k ≤ 50
- 0 ≤ l ≤ r < length of sk
- 1 ≤ |r−l+1| ≤ 100
Output
For each testcase, print |r−l+1| characters,sk[l],sk[l+1],...sk[r−1],sk[r], for a line.
Remember ‘\n’ on the end of each line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
In this problem we simulate a simple text editor. Given a series of keyboard input, output the final text content. Initially, the text content is empty and the cursor is at the beginning of the line. The user can:
-
Insert a lower-case character ('a-z') before the cursor, denoted as a lower-case character.
-
Erase an character before the cursor, denoted as
B. -
Move the cursor to the right one character at a time, denoted as
R. -
Move the cursor to the left one character at a time, denoted as
L. -
Move the cursor to the beginning of the line, denoted as
H. -
Move the cursor to the end of the line, denoted as
E. -
Move all characters before the cursor to the end without changing cursor position, denoted as
M -
Move all characters after the cursor to the beginning without changing cursor position, denoted as
N
Hints
In this problem, you are asked to use doubly linked list to reduce the time complexity.
Remember to free memory when a linked list node is deleted. If you get Runtime Error on test case, probably there is something wrong with the pointers or there is memory leak in your program.
Make sure the time complexity is O(1) for each operation, otherwise you may get Time limit exceed
Input
The first line is an integer T (1 <= T <= 50), meaning that there are T subtasks in the input.
In each subtask, there are two lines. The first line is an integer N(1<= N <= 10^6), being the length of the series of keyboard input. The next line is a string of length N, being the series of keyboard input.
It is guaranteed that L and B will not occur when the cursor is in the left-most position, R will not occur when the cursor is in the right-most position.
Output
For each subtask, output the final text content in a single line.