Problem B
Im-parrot-ators

All parrots in the world want to be Kermit the Parrot, and as such he has several im-parrot-ators.
Kermit’s humans asked your help to write a program to decide if a parrot is Kermit or an im-parrot-ator. The humans detailed Kermit’s utterances with the following set of rules:
-
Whenever Kermit sees someone he knows he may say “Hi <name of the person>”. Except for when he sees someone named Daniel. In this case he says “Hi Roger”. Every time Kermit says “Hi Roger” is because he saw someone named Daniel. Note that Kermit never says “Hi Daniel”.
-
Whenever Kermit is given walnuts he says “mmmmmm”. Walnuts can only be offered to Kermit at dinner time, at 8PM. He doesn’t eat walnuts every night. Sometimes Kermit gets excited and says “mmmmmm” several times.
-
When Kermit’s humans work from home he flies to their shoulder, look at the computer screen and ask: “what are you doing”. This is said at most once per day. His humans only work until 5PM.
-
Whenever Kermit sees a cat or a small dog he says “awwww kitty”.
-
Every day, when the sun sets Kermit says “night night”. The sun sets at 7PM. Kermit says “night night” exactly once, at 7PM.
-
Kermit may say “Kermit”, “Kermit Kermit”, or even “Kermit Kermit Kermit” at any time of the day.
-
As the end of every day, when Kermit is ready to sleep, he says “all the birds” (for some unknown reason).
Kermit can say other things, but for the purpose of this problem, let’s assume that this is a complete description of Kermit’s parlance (ie: he never says anything that is not described above).
You are asked to write a program that, given a full description of all Kermit’s utterances in a day (from 5AM to midnight), decide if it can be Kermit or if it’s definitely an im-parrot-ator. If it could be Kermit you should also output a list of things you know happened on that day (see the output description for a full list of things that can be in the output).
Input
Each line contains different utterances by the parrot, in the order in which they were said. All lines are shorter than $50$ characters and contains only letters and spaces. All names consist of a single non-empty word with a capital first letter (note that this implies that Kermit never says “Hi John Smith”, but he may say “Hi Johnsmith”).
The last line of input contains “all the birds”, and it is the only line with exactly this sentence. In other words, if you read “all the birds” you can stop reading the input.
Output
On the first line of output you should write either “Could be Kermit” or “Im-parrot-ator!”. In case the first line of output is “Could be Kermit”, a description of Kermit’s day should follow, using some of the following lines:
-
There was a cat or a small dog
-
He had walnuts
-
His human worked from home
-
He saw <name of the person>
These lines should be outputted in alphabetical order, and without repetitions (even if he, for instance, saw two cats).
Sample Input 1 | Sample Output 1 |
---|---|
Hi Roger Hi Melanie Hi Roger Hi Sabonette night night Kermit Kermit Kermit mmmmmm Kermit all the birds |
Could be Kermit He had walnuts He saw Daniel He saw Melanie He saw Sabonette |
Sample Input 2 | Sample Output 2 |
---|---|
Hi Roger Hi Melanie Hi Roger Hi Sabonette night night Kermit Kermit Kermit mmmmmm Kermit I am definitely Kermit all the birds |
Im-parrot-ator! |
Sample Input 3 | Sample Output 3 |
---|---|
Hi Roger Hi Melanie Hi Roger Hi Sabonette Kermit Kermit Kermit mmmmmm Kermit all the birds |
Im-parrot-ator! |