#Lutece0192. Party Lamps
Party Lamps
Migrated from Lutece 192 Party Lamps
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
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 turnedOFF
and those that areOFF
are turnedON
. - 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. Write a program to determine all the possible final configurations of the N lamps that are consistent with the given information, without repetitions.
Input
No lamp will be listed twice in the input.
Line :
Line : Final value of
Line : Some lamp numbers ON
in the final configuration, separated by one space and terminated by the integer .
Line : Some lamp numbers OFF
in the final configuration, separated by one space and terminated by the integer .
Output
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 1 and the last character represents the state of lamp . A (zero) stands for a lamp that is OFF
, and a (one) 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
Samples
10
1
-1
7 -1
0000000000
0101010101
0110110110
Note
In this case, there are three possible final configurations:
- All lamps are
OFF
- Lamps are
OFF
and lamps areON
. - Lamps are
OFF
and lamps areON
.
Resources
USACO TRAINING selected by rectaflex