Dance
Time limit1sMemory limit128 MB
Check a sequence of dance steps against five textual rules and report which rules it violates, uppercasing any misplaced dip.
- Level
Easy3 of 10
- Topics
- Implementation, String, Simulation
- Solved
- No attempts yet
Problem
Changyoung is learning to dance. A dance is a single line of steps separated by spaces, and it must follow these five rules.
- A
dipmay only be danced in one of these three situations:- immediately after a
jiggle(e.g.... jiggle dip ...) - two steps after a
jiggle(e.g.... jiggle stomp dip ...) - immediately before a
twirl(e.g.... dip twirl ...)
- immediately after a
- Every dance must end with
clap stomp clap. - If
twirlis danced at least once, thenhopmust be danced at least once as well. - A dance may not start with
jiggle. dipmust be danced at least once.
Given the dance Changyoung performed, write a program that determines whether it obeys all of the rules.
Input
The input consists of several test cases. Each test case is a single line containing one dance. A dance has at most 1000 steps; each step consists of lowercase letters only and is at most 100 characters long. Input continues until end of file.
Output
Print one line for each test case.
- If the dance obeys every rule, print
form ok:followed by the dance exactly as given. - If the dance breaks exactly one rule, print
form error K:followed by the dance, whereKis the number of the broken rule. - If the dance breaks two or more rules, print
form errors K(1), K(2), ..., K(N-1) and K(N):followed by the dance. The broken rule numbersK(i)are listed in ascending order.
When printing the dance, every dip that breaks rule 1 (danced in an invalid position) must be printed in uppercase as DIP.