Skip to content

Commit 3edc053

Browse files
zaqquumMingguriguri
authored andcommitted
[BOJ]#11723. 집합/실버5/30min
https://www.acmicpc.net/problem/11723
1 parent 064d9ab commit 3edc053

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Hongjoo/백준/집합.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
[BOJ]#11723. 집합 / 실버5 / 비트마스킹
3+
문제 : https://www.acmicpc.net/problem/11723
4+
# PROBLEM
5+
add x / remove x / check x . toggle x /
6+
all , empty
7+
"""
8+
import sys
9+
input = sys.stdin.readline
10+
# answer = []
11+
M = int(input())
12+
s = [ 0 for _ in range(21)] # 1<=x <=20 숫자 제한 존재함
13+
for _ in range(M) :
14+
operations = list(input().split())
15+
# 1. empty, all
16+
if len(operations) <2 :
17+
if operations[0] == "all" :
18+
s = [1 for _ in range(21)]
19+
elif operations[0] == "empty" :
20+
s = [0 for _ in range(21)]
21+
# 2. add, remove , check , toggle
22+
else :
23+
ops , x = operations
24+
if ops == "add" :
25+
s[int(x)] = s[int(x)] | 1
26+
elif ops == "remove" :
27+
s[int(x)] = s[int(x)] & 0
28+
elif ops == "check" :
29+
print(s[int(x)])
30+
# answer.append(s[int(x)])
31+
elif ops == "toggle" : # NAND - 같으면 0 , 다르면 1
32+
s[int(x)] = s[int(x)]^1
33+
34+
# #3. 결과 출력
35+
# for a in answer:
36+
# print(a)

0 commit comments

Comments
 (0)