Opening the Box
Time limit2sMemory limit512 MB
Find the minimum number of fixed simultaneous multi-button tests needed to identify the one correct button among N, and output the sets.
- Level
Medium7 of 10
- Topics
- Combinatorics, Math, Implementation, Bit manipulation
- Solved
- No attempts yet
Problem
Hyeonuk spent a year helping his master train in a mysterious jungle and received a treasure box as a reward. The box has buttons, numbered 1 through . Exactly one of them opens the box and the rest are wrong buttons. If you press only one button and it is a wrong button, the box can never be opened again.
You can press several buttons at the same time. When you press several at once, the box makes a ding-dong sound if the buttons you pressed include the correct button, and a beep-beep sound otherwise. In this case, pressing only wrong buttons does not make the box impossible to open.
However, when you press several buttons at once, the answer does not come immediately: the sound is made about 10 to 20 minutes after you press them. Hyeonuk is impatient and wants to find out which button is correct as quickly as possible.
Hyeonuk also hates thinking, so he wants a method that presses a fixed set of buttons in sequence and reads the correct button directly from the results. In other words, he wants a method that finds the correct button no matter which button it is, as long as he presses the same fixed sequence of button sets.
Help Hyeonuk by writing a program that outputs the minimum number of button presses whose results must be checked to determine the correct button in every case, along with the set of buttons to press for each of those presses.
Input
The first line gives the integer .
Output
On the first line, print the minimum number of tests .
From the second line, print the button sets to press, one per line, over lines. The first number on each line is the number of buttons to press at once, followed by the button numbers to press together. must be at least 2.
If there are multiple answers, you may print any of them.