목차

Party Lamps

ps
링크acmicpc.net/…
출처BOJ
문제 번호5508
문제명Party Lamps
레벨골드 1
분류

애드혹

시간복잡도O(n)
인풋사이즈n<=100
사용한 언어Python 3.11
제출기록31256KB / 44ms
최고기록40ms
해결날짜2023/07/19

풀이

코드

"""Solution code for "BOJ 5508. Party Lamps".

- Problem link: https://www.acmicpc.net/problem/5508
- Solution link: http://www.teferi.net/ps/problems/boj/5508

Tags: [ad hoc]
"""

ON = '1'
OFF = '0'
PATTERNS = (
    ('111111', (1,)),
    ('000000', (0,)),
    ('010101', (0,)),
    ('101010', (0,)),
    ('011011', (0, 2)),
    ('100100', (0, 1)),
    ('110001', (0, 1)),
    ('001110', (0, 1)),
)


def main():
    N = int(input())
    C = int(input())
    on_lamps = [int(x) - 1 for x in input().split()][:-1]
    off_lamps = [int(x) - 1 for x in input().split()][:-1]

    for pat, invalid_nums in PATTERNS:
        if (
            C not in invalid_nums
            and all(pat[x % 6] == ON for x in on_lamps)
            and all(pat[x % 6] == OFF for x in off_lamps)
        ):
            print(pat * (N // 6) + pat[: N % 6])


if __name__ == '__main__':
    main()