Maths Olympiad Prep

Library / /47 of 87

Combinatorics Difficulty 6.4 National Olympiad Prove it Serbia

Problem:

A guard proposes the following game to the prisoners. All of them will be brought out into the courtyard, where each of them will have placed on his head a hat of one of 5 possible colors. The guard will then line them up in a row so that each prisoner sees all the hats except his own, and will ask the first prisoner in the row whether he knows the color of his own hat. The prisoner answers aloud "yes" or "no". If he answers "no", he will be immediately locked up in solitary confinement. If he answers "yes", the guard will ask him what color his hat is, to which the prisoner must answer in such a way that the other prisoners cannot hear the answer. If the answer is wrong, that prisoner will be immediately locked up in solitary confinement in front of everyone, and if the answer is correct, that prisoner will be immediately released in front of everyone. The guard then approaches the next prisoner in line and repeats the same procedure, and so on until the last prisoner. The prisoners have the opportunity to devise a strategy before the game begins, but once the game starts, no communication among the prisoners is allowed. If there are 2015 prisoners in the prison, what is the maximum number of prisoners who are guaranteed to be freed if the prisoners use an optimal strategy?

Solution

Solution:

Let us assign the colors the values 0,1,2,3,40,1,2,3,4 and denote by BB the color of the second prisoner's hat, and by SS the sum of the colors of the hats of the third through the last prisoner modulo 5. We will describe a strategy for the first two prisoners after which all the remaining prisoners will know SS, and thus, knowing the colors of the other hats, will be able to determine their own. In this way, freedom will be guaranteed for at least 2013 prisoners. The first prisoner answers "no" if S{0,B,B+1}S \in\{0, B, B+1\} or (B,S)=(4,1)(B, S)=(4,1). To this the second answers "no" if S=0S=0, and otherwise says "yes" and gives the guard the answer SS. In this way, if two "no" answers are heard, the others know that S=0S=0. If the second says "yes" and is freed, the others know that S=BS=B, while otherwise they know that S=B+1S=B+1 if B4B \neq 4, i.e. that S=1S=1 if B=4B=4.

In the remaining cases the first prisoner says "yes" (it is irrelevant what happens to him). To this the second says "yes" if S{2,4}S \in\{2,4\} and gives the guard the answer S2S-2. If B=0B=0, then S{0,1}S \notin\{0,1\}, so the others know that S=2S=2 if the second is freed, S=3S=3 if he says "no", and S=4S=4 if he says "yes" and misses. Finally, if B0B \neq 0, then in view of the affirmative answer of the first, SB+2S \equiv B+2 or SB+3 (mod 4)S \equiv B+3\ (\bmod\ 4) holds, and the second's answer determines the parity of SS, which enables the others to determine SS.

It remains to prove that no strategy guarantees the freedom of 2014 prisoners. Suppose that such a strategy exists and consider a set of five arrangements which differ only in the color of the second prisoner's hat. In at most one of these arrangements does the strategy predict that the first says "no" (otherwise the second could not determine the color of his own hat with certainty). In at least three of the remaining four arrangements the first would have to miss, so the second would not be able to determine the color of his own hat. This completes the proof.

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement translated into English from sr; metadata (topic, difficulty) added by this project.