printРабочее место участника

printЗадачи

1183. Romulan spelling

Ограничения: время – 1s/2s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Year 2000 ACM (after computing machinery). The Romula is a lost human colony near `β` Canopguk. The Romulans use a language that can be approximated with the English alphabet and normal punctuation marks. Their spelling rules are even stranger than English, however. In particular, they have a rule that states:
G before P except after E or when pronounced X as in "npgukbor" or "wpguk".
Operationally, you can detect the X pronounciation by the string PGUK appearing in the word. Also, the Romulan rules for capitalization are different from ours, so capital letters can appear anywhere in a word.
Input and Output
Given a file containing lines of Romulan text, you are to output the text with spelling corrected according to the G before P except after E rule given above. No input line will contain more than 70 characters including spaces and don't include the substring PGPUK.
For example, the input file corresponding to the romulan translation of the quote:
"I received the wierd piece of pie from my neighbor sam who in turn recieved the weird peice of pei from his nieghbor harry," might well be…

Input Sample

I rpEpgvpd tKp wgprd tgpEp of tgp from my npguKbor sam wKo gn
turn rpEgpvpd tKp wpgrd tpgEp of tpg from Kgs ngpuKbor Karry,

Output Sample

I rpEpgvpd tKp wgprd tgpEp of tgp from my npguKbor sam wKo gn
turn rpEpgvpd tKp wgprd tgpEp of tgp from Kgs npguKbor Karry,
Source: uva 373
loading