编程介的小学生 2017-02-13 12:00 采纳率: 20.5%
浏览 1046
已采纳

Dance

Problem Description
For a dance to be proper in the Altered Culture of Machinema, it must abide by the following rules:

  1. A dip can only appear 1 or 2 steps after a jiggle, or before a twirl, as in:
  2. ...jiggle dip...
  3. ...jiggle stomp dip...
  4. ...dip twirl...
  5. All dances end with a clap stomp clap.
  6. If a dance contains a twirl, it must have a hop.
  7. No dance can start with a jiggle.
  8. All dances must have a dip.

As instructor at a dance composition school, you must grade many freshman attempts at composing dances. You decide to make an automatic grader that can check against these rules.

Input
The input consists of a number of dances, one per line. Each dance has a maximum of 1000 steps. Each step is separated by a single space, and all steps are lowercase alphabetic words at most 100 letters long.

Output
If a dance in the input has no mistakes, then the output should contain the words "form ok: " followed by the original composition.

If a dance has a single type of form error, then the output should contain the words "form error K: " where K is the rule which failed, followed by the composition.

If a dance has multiple types of form errors, then the output should contain the errors as a comma separated clause, as in "form errors K(1), K(2), ..., K(N-1) and K(N): " where the form errors are in increasing order, followed by the composition.

If a dance has form error 1, every dip in the dance that violates rule 1 should be printed in upper case.

Sample Input
dip twirl hop jiggle hop hop clap stomp clap dip hop jiggle hop hop clap stomp clap dip twirl hop jiggle hop hop clap clap stomp jiggle dip twirl hop jiggle hop hop clap stomp clap jiggle dip jiggle dip twirl hop dip jiggle hop dip hop clap stomp clap

Sample Output
form ok: dip twirl hop jiggle hop hop clap stomp clap form error 1: DIP hop jiggle hop hop clap stomp clap form error 2: dip twirl hop jiggle hop hop clap clap stomp form error 4: jiggle dip twirl hop jiggle hop hop clap stomp clap form errors 2 and 4: jiggle dip form errors 2, 4 and 5: jiggle form error 1: dip twirl hop DIP jiggle hop dip hop clap stomp clap

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-02-17 20:47
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝