Tag: bitmask
All the articles with the tag "bitmask".
BOJ11723SILVER 5
m = int(input())
s = 0 # 비트마스크
for _ in range(m):
command = input().strip().split()
if command[0] == 'add':
x = int(command[1])
s |= (1 << x)
elif command[0] == 'remove':
x = int(command[1])
s &= ~(1 << x)
elif command[0] == 'check':
x = int(command[1])
print(1 if s & (1 << x) else 0)
elif command[0] == 'toggle':
x = int(command[1])
s ^= (1 << x)
elif command[0] == 'all':
s = (1 << 21) - 1
elif command[0] == 'empty':
s = 0집합
백준 11723번 '집합' (실버 5) 문제 풀이. implementation, set, bitmask 로 접근했다.