z-skocko
Little Z has decided to play a game with you. The game he chose is a game from a TV show that he liked a lot when he was younger.
The goal of the game is to guess a sequence of n numbers, where each number is from the interval [0, 3].
You can guess 2n times, and after each guess little Z will give you some feedback. More specifically, little Z will tell you how many correct numbers you have guessed, and how many of them are positioned exactly where they should be.
For example, if Z's secret sequence is 1 1 2 0
And you guessed2 1 1 1
Little Z will tell you that you have correctly guessed 3 numbers (one 2, and two 1s), and he will also tell you that only one of them is at the correct position.
Now, let's play the game with little z
When Z replies with a = b = n. That means you have guessed all the numbers correctly, and you've also positioned them correctly, hence, you've guessed the sequence. After you get this, you can terminate your program.
You have at most 2n attempts. Any further attempt will not give you any feedback.
Also, make sure you ALWAYS flush the output before waiting for Z's feedback. After writing the sequence, use:
cout.flush() in c++
fflush(stdout) in c
flush(output) in pascalRead: 4
Write: 0 0 1 1
Read: 2 1
Write: 2 2 3 3
Read: 2 0
Write: 0 1 2 3
Read: 3 3
Write: 3 3 3 3
Read: 0 0
Write: 0 0 0 0
Read: 1 1
Write: 0 2 1 2
Read: 4 2
Write: 1 0 2 2
Read: 4 2
Write: 0 1 2 2
Read: 4 4
TerminateRead: 4
Write: 0 0 1 1
Read: 2 0
Write: 2 3 2 3
Read: 2 1
Write: 1 2 3 3
Read: 3 3
Write: 1 1 3 3
Read: 4 4
Terminate
TerminateThe examples above do not show any strategy - these are just random guesses that help understand what the number of correct guesses, and number of correct and correctly positioned guesses are
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.