397. Text Editor
Memory limit: 65536 kilobytes
output: standard
The simplest text editor "Open Word" allows to create and edit only one word. The editor processes keys 'a' -- 'z', and also 'L' (to the left) and 'R' (to the right). After starting his work the editor immediately creates an empty word and sets its cursor to the left-most position. When one of keys 'a' -- 'z' is pressed, the text editor inserts corresponding symbol just after the cursor. After that a cursor moves one position to the right in such a way that it is placed just after new symbol. When key 'L' or 'R' is pressed, the cursor moves one position to the left or to the right respectively. If the cursor can't be moved because it is placed at the left-most or right-most position the command is ignored. Developers of "Open Word" didn't think about the effectiveness so the editor is working slowly if a lot of keys have been pressed.
Your task is to write a program that can process a sequence of key pressings emulating this editor and output result string.
The input file contains one string which consists of symbols ' ' -- ' ', ' ' and ' '. The string length is not less than 1 and doesn't exceed .
Write a required string to the output file.
sample input | sample output |
abLcd | acdb |
sample input | sample output |
icpLLLLLacmRRRRRRRRRRRRc | acmicpc |
这个题目题意很简单,就是要写一个支持插入,左移光标,右移光标操作的文本编辑器,用双向链表就可以完美解决。但是我一开始用scanf("%s",str)将字符串都读入来再处理,就TLE on test54 后来改为读一个字符就处理一个字符,就AC了 ,966ms 汗一个-.-b