Canadian Computing Competition: 2001 Stage 2, Day 1, Problem 2
Anybody who has been to a child's birthday has seen the following scenario:
Parent: OK Kids, what do you want to drink, Coke or Chocolate Milk?
Jamie: Coke
John: I hate Coke
Mary: I want what John is having
Barry: Ick! Then I don't want it if she's going to have it
… etc.
This is a large party. 1000 people have been invited and nearly that number may show up. Can you make everybody happy?
Input Specification
The input may contain several test cases. The first line of each test case is an integer , the number of requests that must be satisfied. Following this line are the requests, each on its own line. Each request has one of these formats:
<person> wants <drink>
<person> hates <drink>
<person> wants same as <person>
<person> wants different from <person>
<person> wants <drink> if <person> gets <drink>
<person>
is the name of a person - up to 20 lower-case letters. <drink>
is either Coke
or chocolate milk
.
If it is possible to make everybody happy, print one line per person, in alphabetical order, with the format:
<person> gets <drink>
If there is more than one way to make everybody happy (fat chance!), fill their glasses in alphabetical order and pour Coke (it's cheaper) whenever there is a choice. If it is not possible to make everybody happy, print:
Everybody gets water
Output Specification
Output a blank line after each test case. The input ends with 0 for the value of .
Sample Input
4
jamie wants Coke
john hates Coke
mary wants same as john
barry wants different from mary
0
Sample Output
barry gets Coke
jamie gets Coke
john gets chocolate milk
mary gets chocolate milk
Comments
can people be named "if"?