Skip to content

Commit 7303a2b

Browse files
committed
[Silver V] Title: 집합, Time: 964 ms, Memory: 128772 KB -BaekjoonHub
1 parent 42b2361 commit 7303a2b

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

백준/Silver/11723. 집합/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
import sys
2-
S = []
2+
S = 0
33
M = int(input())
44
for 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)

0 commit comments

Comments
 (0)