2001 Canadian Computing Competition, Stage 2
Day 1, Problem 2: Coke or Chocolate Milk
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.
Input
The input may contain several test cases. The first line of each test case is an integer N, the number of requests that must be satisfied. Following this line are the N 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.
Output
If it is possible to make everybody happy, print one line per person, in alphabetical order, with the formatBe sure to correctly capitalize the drinks (Coke, chocolate milk).<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
Output a blank line after each test case. The input ends with 0 for the value of N.Everybody gets water
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
All Submissions
Best Solutions
Point Value: 20
Time Limit: 2.00s
Memory Limit: 16M
Added: Apr 18, 2009
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)