황소개발자
백준 11723 파이썬 python : 집합 @@황소처럼 우직하게@@ 본문
반응형
import sys
input = sys.stdin.readline
S = []
def do(order, num):
global S
if order == 'add':
if num not in S:
S.append(num)
elif order == 'remove':
if num in S:
S.remove(num)
elif order == 'check':
if num in S:
print(1)
else:
print(0)
elif order == 'toggle':
if num in S:
S.remove(num)
else:
S.append(num)
elif order == 'all':
S = [i for i in range(1, 21)]
elif order == 'empty':
S = []
n = int(input())
for i in range(n):
s = input().strip()
if s == 'all' or s == 'empty':
do(s, 0)
continue
s = s.split()
do(s[0], int(s[1]))
반응형
'백준 문제 풀이' 카테고리의 다른 글
백준 15650 파이썬 python : N과 M (2) @@황소처럼 우직하게@@ 아아 (0) | 2020.03.01 |
---|---|
백준 15649 파이썬 python : N과 M (1) @@황소처럼 우직하게@@ 숏코딩 (0) | 2020.03.01 |
백준 14501 파이썬 python : 퇴사 @@황소처럼 우직하게@@ 재귀로 간단구현 (10) | 2020.02.28 |
백준 1182 파이썬 python : 부분수열의 합 @@황소처럼 우직하게@@ (0) | 2020.02.28 |
백준 1759 파이썬 python : 암호 만들기 @@황소처럼 우직하게@@ 코로나 조심하세요 (0) | 2020.02.28 |
Comments