b772. 50010. Word Editor
標籤 : 字串處理
通過比率 : 51人/97人 ( 53% ) [非即時]
評分方式:
Tolerant

最近更新 : 2016-01-13 14:22

內容

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
    Both $x$ and $y$ are character. You need to replace all occurrence of $x$ by $y$.
  • remove x
    Remove all occurrence of $x$.
  • addhead x
    Add a character $x$ at the beginning of the word.
  • addtail x
    Add a character $x$ at the end of the word.
  • end
    Stop the computation. It is guarantee the last command is always an 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$

範例輸入 #1
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
範例輸出 #1
apadfeds
invalid command addpangfeng
測資資訊:
記憶體限制: 64 MB
提示 :
標籤:
字串處理
出處:
NTU批改娘計算機程式設計課程 [管理者: morris1028 (碼畜) ]

本題狀況 本題討論 排行

編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」