Broken Keyboard cont.
本題為 UVA 11988 - Broken Keyboard (a.k.a. Beiju Text) 之修改。You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets automatically pressed (internally).
Furthermore, "Backspace" and "Delete" also get triggered unknowingly from time to time.You're not aware of this issue, since you're focusing on the text and did not even tu on the monitor! After you finished typing, you can see a text on the screen (if you tu on the monitor). In Chinese, we can call it Beiju. Your task is to find the Beiju text.
輸入格式
There are several test cases. Each test case is a single line containing at least one and at most \(10,000,000\) letters, underscores and two special characters '[' and ']'.
'[' means the "Home" key is pressed internally, and ']' means the "End" key is pressed internally.
In addittion, '-' represents "Backspace" key down while '|' indicates "Delete" key being triggered.
The input is terminated by end-of-file (EOF).
輸出格式
For each case, print the Beiju text on the screen.
範例輸入
This_is_a_[Beiju]_text
word[hi,_ddc---]-ld[||hello
範例輸出
BeijuThis_is_a__text
hello,_world
提示
本題為多筆輸入,每行獨立處理。
vector, list 的費時,相差高達 374.07
倍!!八分五十一秒,我都快睡著惹。
cont.
相對地,list 的記憶體用量137964 KB
為 vector 的 11 倍。以空間換取時間,非常划算喇!!
留言