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 yremove xaddhead xaddtail xendFor 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
| 編號 | 身分 | 題目 | 主題 | 人氣 | 發表日期 |
| 45898 |
|
b772 | 157 | 2025-04-25 13:06 | |
| 45896 |
|
b772 | 142 | 2025-04-25 13:03 | |
| 45433 |
|
b772 | 175 | 2025-03-04 01:36 |