์ƒˆ์†Œ์‹

๐Ÿงฎ PS

๋ฐฑ์ค€ (boj) 11723 ํŒŒ์ด์ฌ - ์ง‘ํ•ฉ

  • -

๋ฌธ์ œ ๋งํฌ : https://www.acmicpc.net/problem/11723

 

11723๋ฒˆ: ์ง‘ํ•ฉ

์ฒซ์งธ ์ค„์— ์ˆ˜ํ–‰ํ•ด์•ผ ํ•˜๋Š” ์—ฐ์‚ฐ์˜ ์ˆ˜ M (1 ≤ M ≤ 3,000,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ M๊ฐœ์˜ ์ค„์— ์ˆ˜ํ–‰ํ•ด์•ผ ํ•˜๋Š” ์—ฐ์‚ฐ์ด ํ•œ ์ค„์— ํ•˜๋‚˜์”ฉ ์ฃผ์–ด์ง„๋‹ค.

www.acmicpc.net

 

 

 

 

import sys
input = sys.stdin.readline

s = []


def boj(command,x):
    global s
    if command == "add":
        if x not in s:
            s.append(x)
    elif command == "remove":
        if x in s:
            s.remove(x)
    elif command == "check":
        if x in s: 
            print(1)
        else : 
            print(0)
    elif command == "toggle":
        if x in s : s.remove(x)
        else : s.append(x)
    elif command == "all" : s = [i for i in range(1,21)]
    elif command == "empty" : s=[]

M = int(input())

for _ in range(M):
    command = input().strip()
    if command == "all" or command == "empty" :
        boj(command,0)
    else : 
        command,x = command.split()
        boj(str(command),int(x))



Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.