Pro.ID10138 TitleParty Lamps Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10138 AC29 Submit92 Ratio31.52% 时间&空间限制描述To brighten up the gala dinner of the IOI'98 we have a set of N ( 10 ≤ N ≤ 100 ) colored lamps numbered from 1 to N. The lamps are connected to four buttons:
A counter C records the total number of button presses. When the party starts, all the lamps are ON and the counter C is set to zero. You are given the value of counter C ( 0 ≤ C ≤ 10000 ) 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. 输入No lamp will be listed twice in the input. Multiple test cases. Each case has 4 lines: Line 1: N Line 2: Final value of C Line 3: Some lamp numbers ON in the final configuration, separated by one space and terminated by the integer -1. Line 4: Some lamp numbers OFF in the final configuration, separated by one space and terminated by the integer -1. 输出Description To brighten up the gala dinner of the IOI'98 we have a set of N ( 10 ≤ N ≤ 100 ) colored lamps numbered from 1 to N. The lamps are connected to four buttons:
A counter C records the total number of button presses. When the party starts, all the lamps are ON and the counter C is set to zero. You are given the value of counter C ( 0 ≤ C ≤ 10000 ) 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. Multiple test cases. Each case has 4 lines: Line 1: N Line 2: Final value of C Line 3: Some lamp numbers ON in the final configuration, separated by one space and terminated by the integer -1. Line 4: Some lamp numbers OFF in the final configuration, separated by one space and terminated by the integer -1. Output For each case, output lines with all the possible final configurations (without repetitions) of all the lamps. Each line has N characters, where the first character represents the state of lamp 1 and the last character represents the state of lamp N. A 0 (zero) stands for a lamp that is OFF, and a 1 (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' Output a blank line after each case. Sample Input 10 Sample Output 0000000000 Hint In first case, there are 10 lamps and only one button has been pressed. Lamp 7 is OFF in the final configuration. In this case, there are three possible final configurations:
Source 样例输入10 样例输出0000000000 提示In first case, there are 10 lamps and only one button has been pressed. Lamp 7 is OFF in the final configuration. In this case, there are three possible final configurations:
|