DWITE '12 R1 #3 - Costume Party

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
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 1 \le N \le 20, a number of friends Alice will call, followed by N 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 SPOOKY instead.

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 .

Sample Input

4
bob casper
carrie scooby
jim casper
sam casper
3
tommy mummy
billy reaper
jim casper

Sample Output

jim sam
SPOOKY

Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


Comments

There are no comments at the moment.