| 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()