Guess Who
Time limit1sMemory limit1024 MB
Count the characters whose attributes match every given answer, then print the index if exactly one matches or the number of matches otherwise.
- Level
Easy2 of 10
- Topics
- Implementation
- Solved
- No attempts yet
Statement
Guess Who is a two-player board game. Each character is uniquely identified by a set of attributes, such as wearing glasses. Each player tries to guess the other player's hidden character by asking yes/no questions, such as whether the character wears glasses.
In this variation, there are characters, and each one is uniquely identified by a set of attributes. Each attribute value is either YES or NO. You are given the list of characters and their attributes, along with questions and their answers. Determine the hidden character if possible.
Input
The first line contains three space-separated integers , , and , where , , and . The next lines each contain a string of characters, each either Y or N. The th line gives the attribute values of the th character.
Each of the next lines contains an integer (), a space, and a character Y or N. This means the question is about attribute , and the hidden character's value for that attribute is YES or NO. There is at most one question per attribute. At least one listed character matches the answers to all queries.
Output
On the first line, print unique if exactly one character matches the answers, or ambiguous if more than one does.
If the hidden character is unique, print its index (between 1 and ) on the second line. If there are multiple possible characters, print how many of them match on the second line.