当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3136:Taunt Generation Simulator

题目描述
In all the annals of knighthood, no personality trait has been in more dire need than the fortitude to withstand the diplomatically deleterious effects of a vicious, relentless taunting. Tasked with strengthening the mental endurance of Camelot’s knights, King Arthur's court decided that instructional taunting must be applied, yet it could not be delivered by the chivalrous administration. Thus, Sir Lancelot commanded a local anarcho-syndicalist peasant to write a program that generates taunts (a.k.a. mudslinging) thereby producing a script to test the patience of knights in a training environment. To prevent unbridled creativity in taunting from spoiling the otherwise stately proceedings of a nobleman’s education, the following rules designed by committee (The Round Table) must be adhered to:

<taunt> ::= <sentence> | <taunt> <sentence> | <noun>! | <sentence>
<sentence> ::= <past-rel> <noun-phrase> | <present-rel> <noun-phrase> | <past-rel> <article> <noun>
<noun-phrase> ::= <article> <modified-noun>
<modified-noun> ::= <noun> | <modifier> <noun>
<modifier> ::= <adjective> | <adverb> <adjective>
<present-rel> ::= your <present-person> <present-verb>
<past-rel> ::= your <past-person> <past-verb>
<present-person> ::= steed | king | first-born
<past-person> ::= mother | father | grandmother | grandfather | godfather
<noun> ::= hamster | coconut | duck | herring | newt | peril | chicken | vole | parrot | mouse | twit
<present-verb> ::= is | “masquerades as”
<past-verb> ::= was | personified
<article> ::= a
<adjective> ::= silly | wicked | sordid | naughty | repulsive | malodorous | ill-tempered
<adverb> ::= conspicuously | categorically | positively | cruelly | incontrovertibly

Note that all phrases in double quotes are to be treated as one word for taunt simulation output.

The number of taunts elicited at any given time is derived from the number of words spoken by the knight. For every three words (or fraction thereof) delivered by the knight, the generator produces one or more taunts in a theater-style script format. In the event that 2 taunts must be produced on a single line, they will be counted as 2 taunts towards the total required. By a mandate from the masses, a word will always contain at least one alphabetic character, and will be separated from other words by at least 1 space.

In exception to the above rules, whenever the program finds the holy grail, which is to say, the letters t-h-e-h-o-l-y-g-r-a-i-l (case insensitive) in that order in a line of input, then the first taunt generated will be displayed by the program as "(A childish hand gesture)".

To ensure all royal quality assurance criteria are met, the program must be demonstrated by a simulation showing the taunts produced from a series of inputs. Each taunt is generated by applying the taunt generation rules until all of the <...> have been replaced with appropriate words. In most cases, you will face a choice of alternate rules for expanding a phrase name. In these cases, you should make a choice as follows: Suppose that this is the kth such choice that you have faced for that rule since the start of program execution, and that you must choose one of n rules for expanding a given kind of phrase. Let the rules for that phrase be numbered from 1…n in the order of appearance above, and then choose rule number ((k-1) mod n) + 1.

Well, get on with it!
输入解释
The input will consist of an unspecified number of lines. Each line will contain a statement uttered by a knight consisting of letters, digits, the characters ",.-!?" and whitespace. Each line of input will be more than 1 character and less than 72 characters in length. All words will be separated by whitespace. Each statement will contain at least one word.
输出解释
For every line of input, print a block of output containing the following:
  • A single line containing "Knight:", a space, and the input. Any appearance of whitespace inside the input will be replaced by a single space.

  • All taunts (as explained in the above rules) prefaced by "Taunter:" and a space, the taunt, and a period. Each word should be separated from neighboring words by a single space.

  • A blank line
Each taunt should begin with a capital letter, and no extra characters should be added.
输入样例
Hello!
Are you feeling alright?
Is there someone else I could talk to?
Anyone at all?
We seek the holy grail . . .
输出样例
Knight: Hello!
Taunter: Your mother was a hamster.

Knight: Are you feeling alright?
Taunter: Coconut! Your steed is a silly duck.

Knight: Is there someone else I could talk to?
Taunter: Your father personified a herring.
Taunter: Your grandmother was a newt.
Taunter: Peril! Your king masquerades as a conspicuously wicked chicken.

Knight: Anyone at all?
Taunter: Your grandfather personified a vole.

Knight: We seek the holy grail . . .
Taunter: (A childish hand gesture).
Taunter: Your godfather was a parrot.
来自杭电HDUOJ的附加信息
Recommend chenrui

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3136

最后修改于 2020-10-25T23:00:27+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 32768/32768K(Java/Others)