现在的位置: 首页 > 综合 > 正文

sgu 397 TextEditor

2018年04月05日 ⁄ 综合 ⁄ 共 2357字 ⁄ 字号 评论关闭

397. Text Editor

Time limit per test: 8

second(s)
Memory limit: 65536
kilobytes

input: standard
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.

Input

The input file contains one string which consists of symbols '
' -- '
', '
' and '
'. The string length is not less than 1 and doesn't exceed
.

Output

Write a required string to the output file.

Example(s)
sample input
sample output
abLcd
acdb

 

sample input
sample output
icpLLLLLacmRRRRRRRRRRRRc
acmicpc

这个题目题意很简单,就是要写一个支持插入,左移光标,右移光标操作的文本编辑器,用双向链表就可以完美解决。但是我一开始用scanf("%s",str)将字符串都读入来再处理,就TLE on test54 后来改为读一个字符就处理一个字符,就AC了 ,966ms 汗一个-.-b

 

 

【上篇】
【下篇】

抱歉!评论已关闭.