BOJ - 11723 - 집합

Updated:

import sys

def solution():
    S = [0 for _ in range(21)]
    N = int(input())
    for i in range(N):
        command = list(map(str, sys.stdin.readline().split()))

        if command[0] == 'all':
            S[0:21] = [1 for _ in range(21)]
        elif command[0] == 'empty':
            S[0:21] = [0 for _ in range(21)]
        elif command[0] == 'add':
            S[int(command[1])] = 1
        elif command[0] == 'remove':
            S[int(command[1])] = 0
        elif command[0] == 'check':
            if S[int(command[1])]: print(1)
            else: print(0)
        elif command[0] == 'toggle':
            if S[int(command[1])]: S[int(command[1])] = 0
            else: S[int(command[1])] = 1
solution()

https://www.acmicpc.net/problem/11723

Categories:

Updated:

Leave a comment