Connection Status:
Competition Arena > Answer
TCO05 Sponsor 2 · 2005-08-16 · by Olexiy · Dynamic Programming
Class Name: Answer
Return Type: int
Method Name: chooseOne
Arg Types: (vector<string>)
Problem Statement

Problem Statement

You are participating in a famous TV Quiz. In the final stage of this quiz you must guess the correct answer for a question posed by the quizmaster. The quizmaster tells you the length of the answer. The quiz consists of one or more turns. On each turn, you may either answer the question or ask for a hint. You must be sure of the solution before answering the question. When asking for a hint, you tell a letter to the quizmaster, and he reveals all occurrences of this letter to you. Unfortunately, your prize decreases with each hint, so you want to win the game with as few hints as possible.

You are given a list of all possible answers in the String[] words. Return the minimal number of hints needed to determine the correct answer.

Constraints

  • words will contain between 2 and 18 elements, inclusive.
  • Each element of words will contain between 1 and 50 characters, inclusive.
  • Each element of words will have the same length.
  • Each element of words will contain only upper-case letters between 'A' and 'Z'.
  • Each elements of words will be distinct.
Examples
0)
{"CAT", "DOG", "ANT"}
Returns: 1

You ask the quizmaster to reveal all occurrences of the letter 'A'. The answer is "ANT" if 'A' happens to be the first letter, "CAT" if it is the second, and "DOG" if no letter was revealed.

1)
{"A", "D", "E"}
Returns: 2
2)
{"A", "D", "E", "B", "C", "H", "I", "Z", "O", "Q"}
Returns: 9
3)
{"DOG", "CAT", "ANT", "DON", "ANN"}
Returns: 2
4)
{"DOG", "CAT", "ANT", "DON", "ANN", "ABC", "AFG", "ABG"}
Returns: 3

Submissions are judged against all 131 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class Answer with a public method int chooseOne(vector<string> words) · 131 test cases · 2 s / 256 MB per case

Submitting as anonymous