ํ’€์ด


๋ฉ”๋ชจ๋ฆฌ์ œํ•œ์ด ๊ฑธ๋ ค์žˆ๋Š” ๋ฌธ์ œ๋ผ ๋น„ํŠธ๋งˆ์Šคํ‚น์ด๋ผ๋Š” ์ƒˆ๋กœ์šด ๊ฐœ๋…์„ ๋ฐฐ์›Œ ์ ์šฉํ–ˆ๋‹ค.

Pypy3 ๋กœ ์ œ์ถœํ–ˆ์„ ๊ฒฝ์šฐ ๋ฉ”๋ชจ๋ฆฌ์ดˆ๊ณผ๊ฐ€ ๋– ์„œ Python3 ๋กœ ์ œ์ถœํ–ˆ๋”๋‹ˆ ๋ฌด๋ฆฌ์—†์ด ํ†ต๊ณผํ–ˆ๋‹ค.

์†Œ์Šค์ฝ”๋“œ


import sys
input = sys.stdin.readline
 
M = int(input())
S = 0
 
for _ in range(M):
    inp = input()
    command = inp.split()[0]
    if command == "add":
        S |= (1 << int(inp.split()[1]))
    elif command == "remove":
        S &= ~(1 << int(inp.split()[1]))
    elif command == "remove":
        S &= ~(1 << int(inp.split()[1]))
    elif command == "check":
        if S & (1 << int(inp.split()[1])):
            print(1)
        else:
            print(0)
    elif command == "toggle":
        S ^= (1 << int(inp.split()[1]))
    elif command == "all":
        S = (1 << 21) - 1
    elif command == "empty":
        S = 0

References