알고리즘
[백준][Python 파이썬] 11723번 집합
룰루루
2023. 11. 24. 17:48
import sys
input = sys.stdin.readline
N = int(input())
S = set()
for _ in range(N):
command = input().strip()
if command == "all":
S = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
elif command == "empty":
S = set()
else:
cmd, elem = command.split()
elem = int(elem)
if cmd == "add":
S.add(elem)
elif cmd == "remove":
if elem in S:
S.remove(elem)
elif cmd == "check":
if elem in S:
print(1)
else:
print(0)
else:
if elem in S:
S.remove(elem)
else:
S.add(elem)