10138_PartyLamps

2022-5-16 18:16| 发布者: Hocassian| 查看: 71| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504590983700-Problem List-采集的数据-后羿采集器.html

Pro.ID

10138

Title

Party Lamps

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10138

AC

29

Submit

92

Ratio

31.52%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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:

    • Button 1: 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 2: Changes the state of all the odd numbered lamps.

    • Button 3: Changes the state of all the even numbered lamps.

    • Button 4: Changes the state of the lamps whose number is of the form 3×K+1 ( with K ≥ 0 ), i.e., 1, 4, 7, ...

    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:

    • Button 1: 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 2: Changes the state of all the odd numbered lamps.

    • Button 3: Changes the state of all the even numbered lamps.

    • Button 4: Changes the state of the lamps whose number is of the form 3×K+1 ( with K ≥ 0 ), i.e., 1, 4, 7, ...

    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
    1
    -1
    7 -1

    10
    0
    -1
    1 -1

    Sample Output

    0000000000
    0101010101
    0110110110

    IMPOSSIBLE

    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:

    • All lamps are OFF

    • Lamps 1, 4, 7, 10 are OFF and lamps 2, 3, 5, 6, 8, 9 are ON.

    • Lamps 1, 3, 5, 7, 9 are OFF and lamps 2, 4, 6, 8, 10 are ON.

    Source

    样例输入

    10
    1
    -1
    7 -1

    10
    0
    -1
    1 -1

    样例输出

    0000000000
    0101010101
    0110110110

    IMPOSSIBLE

    提示

    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:

    • All lamps are OFF

    • Lamps 1, 4, 7, 10 are OFF and lamps 2, 3, 5, 6, 8, 9 are ON.

    • Lamps 1, 3, 5, 7, 9 are OFF and lamps 2, 4, 6, 8, 10 are ON.


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部