File tree Expand file tree Collapse file tree 2 files changed +9
-15
lines changed
Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 128368 KB, 시간: 972 ms
7+ 메모리: 128772 KB, 시간: 964 ms
88
99### 분류
1010
1111비트마스킹, 구현
1212
1313### 제출 일자
1414
15- 2025년 1월 14일 11:22:06
15+ 2025년 1월 14일 11:50:34
1616
1717### 문제 설명
1818
Original file line number Diff line number Diff line change 11import sys
2- S = []
2+ S = 0
33M = int (input ())
44for i in range (M ):
55 A = sys .stdin .readline ().strip ()
6- if A == 'all' : S = [ j for j in range ( 1 , 21 )]
7- elif A == 'empty' : S = []
6+ if A == 'all' : S = ( 1 << 21 ) - 1
7+ elif A == 'empty' : S = 0
88 else :
99 command , num = A .split ()
1010 num = int (num )
11- if command == 'add' :
12- if num not in S : S .append (num )
13- if command == 'remove' :
14- if num in S : S .remove (num )
15- if command == 'check' :
16- if num in S : print (1 )
17- else : print (0 )
18- if command == 'toggle' :
19- if num in S : S .remove (num )
20- else : S .append (num )
11+ if command == 'add' : S |= (1 << num )
12+ if command == 'remove' : S &= ~ (1 << num )
13+ if command == 'check' : print (1 if S & (1 << num ) != 0 else 0 )
14+ if command == 'toggle' : S ^= (1 << num )
You can’t perform that action at this time.
0 commit comments