×_7_12_2013 D: Text Editor

Problem D: Text Editor

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 0   Solved: 0
[ Submit][ Status][ Web Board]

Description

I think everyone here must have used Text pad. Now we define our own rules to write a text editor. We 
regard “FP” as the Final Point, which means that the cursor points to the next position of the last word of the 
line. If we build a new line, but don’t insert any word into it, we assume the line includes nothing. 
This editor must supply next commands: 
1. English lowcase letters or spaces, the editor insert words just before the cursor. 
2. L: move cursor one position left. If current position in the beginning of the line, cursor mustn't move. 
3. R:move cursor one position right. If current position is the “FP”, cursor mustn’t move. 
4. U:move cursor a line up. If the current line is the first line, cursor mustn’t move. 
5. D:move cursor a line down. If the current line is the last, cursor mustn’t move. 
6. H:move cursor to the beginning of the line. 
7. E: move cursor to the “FP”. 
8. N:a new line must be added at the end of the strings. And the cursor must point to the beginning of the 
new line. 
9. X:If the line the cursor points to doesn’t include any word, delete this line, the remaining lines shift up. 
Or delete the current word that the cursor points to. If the cursor points to the “FP”, delete the word before it. 
The remaining part of the line must shift left. And then move the cursor to the first position of the line. If the 
line doesn’t include any word, delete it, shift the remaining lines up, and move the cursor to the first position 
of the first line. 
10. B:If the line the cursor points to doesn’t include any word, delete this line, the remaining lines shift up. 
Or delete the word before the cursor. If the cursor points to the first position of the line, delete the first word. 
The remaining part of the line must shift left. And then move the cursor to the first position of the line. If the 
line doesn’t include any word, delete it, shift the remaining lines up, and move the cursor to the first position 
of the first line. 
The editor starts from a blank file. 
We assume that in any moment while working the num of text lines does not exceed 500, and the length of 
the words does not exceed 2000 per line. The input string’s length does not exceed 100000.

Input

The input there is the only line – the list of commands of editor. 

Output

Output the result of working of the editor. If one line doesn’t include any word, you should not output it, just 
ignore it. After the last line, output “#” (without quotes). Note: we regard space a word. 

Sample Input

abLcd icpLLLLLacmRRRRRRRRRRRRc abcdNNNaXaHEHRRUDULLRRNNBUUUBB lineRoUNLLLLline dDDDNline tline cLLLLLLNEUULLXRRRBXHBBHBBBBsome left output

Sample Output

acdb # acmicpc # bcd # some left outputeo line tline c #



你可能感兴趣的:(×_7_12_2013 D: Text Editor)