SP8795 TWENTYQ - Twenty Questions
Description
Consider a closed world and a set of features that are defined for all the objects in the world. Each feature can be answered with “yes” or “no”. Using those features, we can identify any object from the rest of the ob jects in the world. In other words, each object can be represented as a fixed-length sequence of booleans. Any object is different from other objects by at least
one feature.
You would like to identify an object from others. For this purpose, you can ask a series of questions to someone who knows what the object is. Every question you can ask is about one of the features. He/she immediately answers each question with “yes” or “no” correctly. You can choose the next question after you get the answer to the previous question.
You kindly pay the answerer 100 yen as a tip for each question. Because you don’t have surplus money, it is necessary to minimize the number of questions in the worst case. You don’t know what is the correct answer, but fortunately know all the ob jects in the world. Therefore, you can plan an optimal strategy before you start questioning.
The problem you have to solve is: given a set of boolean-encoded objects, minimize the maximum number of questions by which every object in the set is identifiable.
Input Format
The input is a sequence of multiple datasets. Each dataset begins with a line which consists of two integers, _m_ and _n_: the number of features, and the number of ob jects, respectively. You can assume 0 < _m_ n
The end of the input is indicated by a line containing two zeros.
Output Format
For each dataset, minimize the maximum number of questions by which every object is identi-
fiable and output the result.