Hide

Problem E
Sneaky Mastermind

Rebecka and Hugo are playing a round of Mastermind, where Hugo has created a secret code consisting of $N$ coloured pegs. There are $C$ different colours on the pegs and Hugo is allowed to use multiple pegs of the same colour. Rebecka is tasked with trying to find the secret code. After each guess, Hugo will give Rebecka two numbers, one indicating how many pegs are in the correct position, the other one indicating how many pegs have the correct colour but are in the wrong position.

In one game, Hugo accidentally gave Rebecka an incorrect response to one of her guesses. Hugo noticed that this significantly increased Rebecka’s time to find the correct answer.

From now on, Hugo has therefore decided to sometimes lie and give Rebecka an incorrect response to one of her guesses.

Interactivity

This problem is interactive. First, you will read the integers $N$ and $C$ ($1 \leq N \leq 10$, $2 \leq C \leq 15$), where $N$ is the number of coloured pegs there are in the code and $C$ is the number of different colours the pegs can have. The allowed colors are the $C$ first letters of the alphabet.

Then, you should reply with a guess containing $N$ characters a-o (lowercase) in a single string, where each character represents a different colour.

After each guess, you should read two space separated integers, $X$ and $Y$, where $X$ is the number of pegs with both correct place and colour and $Y$ is the number of pegs with correct color but wrong position.

When your program is sure of the solution, it should prepend its guess with an exclamation mark and space, like ! abc. Note that Hugo does not have to cheat, but if he does he will only do so for one of his responses.

Scoring

Your solution will be run on many test cases, each getting as score between $0$ and $100$, with the total score being the arithmetic mean of test case scores. Some test cases have small $N$ and/or $C$ and in some test cases Hugo does not cheat.

The score for a given test case depends on how many more queries your solution requires when compared to the judge solution. For $E$ queries more than the judge solution, you get $100$ points if $E\le 3$ and $100/E$ points otherwise.

At the very most, you can guess 1000 times.

Please log in to submit a solution to this problem

Log in