DWITE, October 2012, Problem 3
Alice wants to hold a costume party for this Halloween. To make things interesting, and to prevent potential fights, she decided to make sure that all her friends will dress up in different costumes for the party. How she does this is by calling her friends one by one and asking them what they were planning on wearing for the party. If they were planning on wearing a costume that someone Alice has already spoken to was planning on wearing, then Alice tells them to wear something else. Being her best friend, she asks you to keep track of the friends she asks to wear something else (in case they need a reminder later on).
The input will contain 5 test cases. Each test case will start with a number , a number of friends Alice will call, followed by lines – a pair of words, a friend's name and their costume (each one word).
The output will contain 5 lines: lists of friends that were asked to change costumes, in the order that they were called. Each list will be a single line, names separated by spaces. If a list is empty, print
Note: since the judge checks if your line is an exact match, make sure not to end the list with an extra space. That is, the first sample is
jim sam not
jim sam .
4 bob casper carrie scooby jim casper sam casper 3 tommy mummy billy reaper jim casper
jim sam SPOOKY