Write a program to edit a word. First you will be given a word consisting of lower letters. Each line afterward is a command. The commands are as follow.
replace x y
remove x
addhead x
addtail x
end
For example, if you are given a word "pangfeng"
, then after "replace g d"
you will have "pandfend"
. Then after "remove n"
you will have "padfed"
. After "addhead a"
you will have "apadfed"
. After "addtail s"
you will have "apadfeds"
.
It has a testdata set. First line contains a string $S$, then following many commands to edit the word.
* $|S| \le 100000$
* $|\text{#valid command}| \le 100000$
* $|\text{invalid command}| \le 20$
pangfeng replace g d remove n addhead a addtail s end pangfeng replace g d remove n addhead a addtail s addpangfeng b addhead a end
apadfeds invalid command addpangfeng
編號 | 身分 | 題目 | 主題 | 人氣 | 發表日期 |
沒有發現任何「解題報告」
|