| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12668 | Text Editor - Linked List Version |
|
Description
Modified from 10389 - text editor
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 alphabet ('a-z') before the cursor, denoted as a lower-case alphabet.
-
Erase an alphabet 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 word at a time, denoted as
L.
Hints
In this problem, you are asked to use doubly linked list to reduce the time complexity. Three typical implementations as follows are possible. You can choose your favorite one, e.g., Impl 1 or Impl 2.

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 <= 106), 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.