|
||||||||||
Firebirds' Logic NationTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 85 Accepted Submission(s): 5 Problem Description In HDU, there is an little world created by GL, WYB, and CTW. This world lives some birds which are recognized as firebirds. Actually, the firebirds' world exists three kind of birds, respectively created by GL, WYB, CTW. So I will call them "Gbird", "Wbird", "Cbird" below. What's more, these birds can talk to ACMers and have their own habit as follows: Gbird are like GL, never tell truth. Wbird like to tell the truth in the day, but lie in the night. While Cbird are all honest, and never lie. Now, some firebirds talk to you and tell you some statements, can you deduce what kind of these birds are, and whether it's day or night? Input The input contains several cases. Each description starts with two integer n and m respectively represent the number of birds and statements. Then following m lines each contain one statement. And one statement is begin with "X: ", X is the identity of speaker. Then follows the contents, like following kinds: I am [not] ( Gbird | Wbird | Cbird | lying ). X is [not] ( Gbird | Wbird | Cbird | lying ). It is ( day | night ). The word in [] may appear or not appear. The word in () mean that exactly one of the words separated by | must appear. X is the identity of birds, it's a uppecase character between 'A' and 'Z'. 0 < n < 27, 0 < m < 100, 'A' <= X <= 'Z'. Input end with a case n = 0 and m = 0. Output For each case, first output a line with "Case #x:", x represent the number of case and start with 1. Then print "You're kidding.", if the conversation cannot happen according to the rules or "I messed up.", if no facts can be deduced. Otherwise print all the facts that can be deduced. Sample Input
Sample Output
Hint hints£º case 1: You cannot reduce anything from it. case 2: If A is lying, then it's telling a truth. If it's telling a truth, it's lying. So it cannot happen according to the rules. case 3: Gbird won't say itself is a Gbird, so C is lying(statement 4 is false). You can reduce that it is night and C is a Wbird. So B is telling the truth(statement 2 is true). It's a Cbird. A is not a Wbird(statement 3 is false) and is not a Cbird(statement 1 is false). So A is a Wbird. Author CTW Source | ||||||||||
|