There is a safe that can be opened by entering a secret code consisting of n digits, each of them is 0 or 1. Initially, n zeros were entered, and the safe is closed (so, all zeros is not the secret code). In one attempt, you can enter an arbitrary sequence of n digits, each of them is 0 or 1. If the entered sequence matches the secret code, the safe will open. If the entered sequence matches the secret code in more positions than the previously entered sequence, you will hear a click. In any other cases the safe will remain locked and there will be no click. Find the smallest number of attempts that is sufficient to open the safe in all cases.
Problem
Source: IOM 2021 #5
Tags: combinatorics
10.12.2021 18:53
Answer: n The strategy is as follows: Assume that the correct sequence is x1x2⋯xn. On the first attempt we put 100⋯0. If the case clicks, then we know for sure that x1=1, and if it doesn't then x1=0. Now that we know what x1 is for sure, on the second attempt we put x1100⋯0. Again, if the case clicks , then x2=1 and otherwise x2=0, so after 2 moves we already know what x1 and x2 are for sure. Assume that after k moves we know what x1 to xk are. Then on the k+1-st move we put x1x2⋯xk100⋯0 and we find out what xk+1 is. If the largest index that is 1 is j<n, then after we put x1x2⋯xj−1100⋯0 the safe would open. Otherwise, on the n-th move we put x1x2⋯xn−11 and we open the case. Now I'll show that we need at least n moves to be sure that we open the case. Consider the set of the 2n−1 sequences of n digits that are either 0 or 1. Define the term remaining sequences at a given time, as the subset of sequences out of those 2n−1 that still may turn out to be the secret code. Note that at any attempt, the subset of remaining sequences divides into two parts - the one that have more matches with the current attempt than with the previous one, and the ones that have no more matches with the current attempt than with the previous one. Note that, if the case doesn't click, the remaining sequences that have more matches with the current attempt than with the previous one are no longer part of the subset of remaining sequences, and if the case clicks , then the remaining sequences that have no more matches with the current attempt than with the previous one will no longer be remaining sequences. But note that we can't guarantee whether the case clicks or not, so if we have x remaining sequences at some point, then after one attempt we can't get rid of more than ⌈x⌉ of them. This tells us that if we have 2n−1 remaining sequences at the start, after 1 attempt we can guarantee at least 2n−1−1, and so on, after n−1 moves at least 2n−(n−1)−1=1, thus we need 1 more attempt to open the case, which makes up for a total of at least n.
10.12.2021 20:59
what is IOM?
10.12.2021 23:29
International Olympiad of Metropolises
26.01.2022 20:06
17.12.2023 23:05
The answer is n. For a construction, let the correct sequence be d1…dn. On the k-th guess put 1 in the k-th position and the known digits d1 through dk−1 in their respective positions. This allows us to deduce dk, which will be 1 iff the case clicks. For a bound: n=1 is trivial. For n≥2 if we only had n−1 guesses then it could be the case that our space of possible codes gets divided by at most 2 in each turn, so after n−1 moves we have at least 2n−12n−1>1 possible codes.