seuOJ581 - 自然拼读法

题目描述

A Plan for the Improvement of English Spelling

For example, in Year 1 that useless letter "c" would be dropped to be replased either by "k" or "s", and likewise "x" would no longer be part of the alphabet. The only kase in which "c" would be retained would be the "ch" formation, which will be dealt with later.

Year 2 might reform "w" spelling, so that "which" and "one" would take the same konsonant, wile Year 3 might well abolish "y" replasing it with "i" and Iear 4 might fiks the "g/j" anomali wonse and for all.

Jenerally, then, the improvement would kontinue iear bai iear with iear 5 doing awai with useless double konsonants, and iears 6-12 or so modifaiing vowlz and the rimeining voist and unvoist konsonants.

Bai Iear 15 or sou, it wud fainali bi posibl tu meik ius ov thi ridandant letez "c", "y" and "x" -- bai now jast a memori in the maindz ov ould doderez -- tu riplais "ch", "sh", and "th" rispektivli.

Fainali, xen, aafte sam 20 iers ov orxogrefkl riform, wi wud hev a lojikl, kohirnt speling in ius xrewawt xe Ingliy-spiking werld.


上面的内容为题目背景,跳过阅读这部分不妨碍解决本题。不过为了方便大家学习英语,我们将借鉴上述更容易拼读的方法重新修改英语单词,形式化地来说:

给定一个小写字母和空格的字符串。你需要对每个字符串按顺序执行下面 1111 条规则,并输出最终结果。

空格的位置与数量必须原样保留,任何规则都不能跨过空格生效。

设当前处理的字符串为 SS,规则如下:

  1. 处理所有不属于 chc
    • 如果该 c 的后一个字符是 eiy,则把它变成 s
    • 否则把它变成 k
  2. 把所有 x 变成 ks
  3. 把所有 wh 变成 w
  4. 对每个 g,如果它的后一个字符是 eiy,则把它变成 j;否则保持不变。
  5. 把所有 y 变成 i
  6. 把所有 ee 变成 i
  7. 把所有 oo 变成 u
  8. 对每一段连续相同的辅音,只保留一个字符。
  9. 把所有 ch 变成 c
  10. 把所有 sh 变成 y
  11. 把所有 th 变成 x

其中,本题中的辅音指所有不属于 aeiou 的小写字母。

注意:所有规则必须严格按照编号顺序执行。第 i+1i + 1 条规则看到的是第 ii 条规则处理后的结果,而不是原字符串。

输入格式

输入一行一个字符串 SS1S100001\le |S|\le 10000),保证每个字符串只包含小写字母和空格,且不存在行首空格、行尾空格、连续两个空格。

输出格式

输出一行一个字符串,表示按题目要求完成全部操作后的结果。

样例

样例 1 输入

which cheese

样例 1 输出

wic cise

样例 1 解释

第一组中,which 会先把 wh 变成 w,再把 ch 变成 c,得到 wiccheese 会先保留开头的 ch,再把 ee 变成 i,最后再把 ch 变成 c,得到 cise

样例 2 输入

giant bookkeeper thx xylophone shell book cool

样例 2 输出

jiant bukiper xks ksilophone yel buk kul

样例 2 解释

第二组中,空格位置始终保持不变;例如 shell 会先在第 88 条规则中把 ll 压成 l,再在第 1010 条规则中把 sh 变成 y,得到 yel

样例 3 输入

max golf xh kan eeee be beaten in one hundred bite

样例 3 输出

maks golf ky kan ii be beaten in one hundred bite

样例 3 解释

根据规则,对于某个单词,有可能会变化多次。

不保证数据中出现的单词在现实世界中存在。

样例 4 输入

whhh wh cycle 

样例 4 输出

wh w sikle

样例 4 解释

whhh->whh->wh