File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 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)
You can’t perform that action at this time.
0 commit comments