题目描述:
题目2 : Mission Impossible 6
时间限制:1000ms
单点时限:1000ms
内存限制:256MB
描述
You must have seen the very famous movie series,”Mission Impossible”, from 1 to 4. And “Mission Impossible 5” is now on screen in China. Tom Cruise is just learning programming through my MOOC course, and he wants a good score. So I made him divulge the story of “Mission Impossible 6”.
In “Mission Impossible 6”, Ethan Hunt risks his life to install a mini camera in Bad Boss’s room, in order to peep at the work Bad Boss does on his computer. Unfortunately, Bad Boss moves his desk to get more sunshine, and after that Ethan can’t see the computer screen through the camera. Fortunately, Ethan can still see the keyboard. So, Ethan wants to know what Bad Boss writes on his computer by watching Bad Boss’s keyboard inputs. That job is neither exciting nor risky, so it’s really impossible for Ethan to accomplish — that’s why Tom Cruise wants to learn programming.
To simplified the problem, we assume that Bad Boss is editing a one line document, and the document consists of only lowercase letters. At first, there are nothing in the text editor window except a caret blinking at the left-most position (the starting position of the line). When Bad Boss input a lowercase letter, the letter appears at the right side of the caret, and then the caret moves to the right side of the letter just inputted. The text editor can switch between “insert mode” and “overwrite mode”. When it’s in “overwrite mode”, the newly inputted letter will overwrite the letter which is on the right of the caret(if there is one). If it’s in “insert mode”, the newly inputted letter will be inserted before the letter which is originally on the right of the caret.
Besides inputting lowercase letters, Bad Boss can do some operations by inputting some uppercase letters, as described below:
‘L’ : Moves the caret toward left by one letter. If the caret is already at the start of the line, then nothing happens.
‘R’: Moves the caret toward right by one letter. If the caret is already at the end of the line(it means that there are no letters on the right side of the caret), then nothing happens.
‘S’: Switch between “overwrite mode” and “insert mode”. At the beginning, it’s in “insert mode”.
‘D’: Delete a letter which is on the right of the caret. If the caret is already at the end of the line, then nothing happens. ‘D’ also has other effect which is described in ‘C’ operation below.
‘B’: Delete a letter which is on the left of the caret. If the caret is already at the start of the line, then nothing happens.
‘C’: Copy something to the clipboard. At first , there is nothing in the clipboard, and the “copy status” of the editor is set to “NOTHING”. When key ‘C’ is pressed:
If copy status is “NOTHING”, copy status will be changed into “START”, and the current position of caret is saved as “copy position 1”.
if copy status is “START “, copy status will be changed into “NOTHING” and the letters between current caret position and the saved “copy position 1” will be copied into clipboard(The old content in the clipboard is replaced). If those two positions are the same, clipboard will be cleared.
Please note that , if any letter except ‘L’ , ‘R’ and ‘D’ is inputted when copy status is “START”, copy status will changed into “NOTHING” immediately, not affecting the inputted letter taking its own effect as mention above. If ‘D’ is inputted when copy status is “START”, copy status will changed into “NOTHING” immediately, and the letters between current caret position and “copy position 1” will be deleted.
‘V’: Paste the content in the clipboard into the right of the caret. If there is nothing in the clipboard, nothing happens. In “insertion mode”, the pasted content is inserted. If it’s in “overwrite mode” and there are k letters in the clipboard, then k letters will be overwrote. In “overwrite mode”, if the number of