Guess Who?

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 512M

Author:
Problem type
Allowed languages
Assembly, C, C#, C++, Go, Haskell, Java, JS, Pascal, Perl, Python, Rust, Sed

Harriet is playing popular game "Guess Who?", in which she has to try guess a particular character based on their features, out of a list of characters. In this game Harriet can make queries about this character, to reduce the possible choices.

Interaction

This is an interactive problem, meaning you read and write your solution simultaneously.

Input will start with two integers, n and f, separate by a space. f lines follow, listing the features each character has. A feature is a single string containing only upper/lower case letters. n lines follow, describing n different characters. Each line contains f space separate strings - the values for each characteristic (Each value is also a string containing only upper/lower case letters).

From here, interaction begins. You can make two possible queries:

  • QUERY A = B: Ask whether the character has value B for feature A. The judge will respond either YES or NO.
  • GUESS x: Guess that the character is index x (1 indexed). After making this query, your code should exit.

Limits

  • You can make at most 20 queries (including GUESS)
  • 1 \leq f \leq 6
  • 1 \leq n \leq 1000
  • Each feature has at most 4 possible values that can appear

Example Interaction

### JUDGE:
4 3
Hair
Eyes
Hat
Brown Blue Cap
Blonde Blue Beanie
Blonde Green None
Grey Brown Beanie
### SOLUTION:
QUERY Eyes = Blue
### JUDGE:
NO
### SOLUTION:
QUERY Hair = Beanie
### JUDGE:
YES
### SOLUTION:
GUESS 4

In this example, the fourth character (With Grey Hair, Brown Eyes, and a Beanie for the Hat) is the character we are trying to guess.


Comments


  • 0
    admin  commented on Oct. 2, 2021, 3:48 p.m.

    sys.exit is causing issues with this problem. If you are getting a NameError issue, please remove it.


  • 0
    syntaxation  commented on Oct. 2, 2021, 2:41 p.m.

    what does our code print in this, and are the ### actual inputs


    • 0
      admin  commented on Oct. 2, 2021, 2:44 p.m.

      No, the ### are just to signify who is printing. In the example, you just print:

      QUERY Eyes = Blue
      QUERY Hair = Beanie
      GUESS 4

  • 0
    admin  commented on Oct. 2, 2021, 12:46 p.m.

    No, but it is guaranteed that the particular character you are trying to guess will have a unique combination


    • 0
      admin  commented on Oct. 2, 2021, 12:46 p.m.

      Also please use clarifications :) I don't get notified about these.


  • 0
    fightUsMonash  commented on Oct. 2, 2021, 12:36 p.m.

    is it guaranteed that each character has a unique combination of attributes?