#P1468. [IOI 1998 / USACO2.2] Party Lamps
[IOI 1998 / USACO2.2] Party Lamps
题目描述
To brighten up the gala dinner of the IOI'98 we have a set of () colored lamps numbered from to .
The lamps are connected to four buttons:
- Button : When this button is pressed, all the lamps change their state: those that are ON are turned OFF and those that are OFF are turned ON.
- Button : Changes the state of all the odd numbered lamps.
- Button : Changes the state of all the even numbered lamps.
- Button : Changes the state of the lamps whose number is of the form (with ), i.e., .
A counter records the total number of button presses.
When the party starts, all the lamps are ON and the counter is set to zero.
You are given the value of counter () and the final state of some of the lamps after some operations have been executed. Determine all the possible final configurations of the lamps that are consistent with the given information, without repetitions.
输入格式
- Line 1: .
- Line 2: Final value of .
- Line 3: Some lamp numbers ON in the final configuration, separated by one space and terminated by the integer .
- Line 4: Some lamp numbers OFF in the final configuration, separated by one space and terminated by the integer .
No lamp will be listed twice in the input.
输出格式
Lines with all the possible final configurations, without repetitions, of all the lamps. Each line has characters, where the first character represents the state of lamp and the last character represents the state of lamp . A 0 stands for a lamp that is OFF, and a 1 stands for a lamp that is ON. The lines must be ordered from least to largest as binary numbers.
If there are no possible configurations, output a single line with the single word IMPOSSIBLE.
10
1
-1
7 -1
0000000000
0101010101
0110110110
提示
Sample explanation
Input
In this case, there are lamps and only one button has been pressed. Lamp is OFF in the final configuration.
Output
In this case, there are three possible final configurations:
- All lamps are OFF.
- Lamps are OFF and lamps are ON.
- Lamps are OFF and lamps are ON.
USACO Training Section 2.2.