[๋ฐฑ์ค-11723] ์งํฉ / Python
๐ Problem Solving/Baekjoon
11723๋ฒ: ์งํฉ
์ฒซ์งธ ์ค์ ์ํํด์ผ ํ๋ ์ฐ์ฐ์ ์ M (1 ≤ M ≤ 3,000,000)์ด ์ฃผ์ด์ง๋ค. ๋์งธ ์ค๋ถํฐ M๊ฐ์ ์ค์ ์ํํด์ผ ํ๋ ์ฐ์ฐ์ด ํ ์ค์ ํ๋์ฉ ์ฃผ์ด์ง๋ค.
www.acmicpc.net
import sys
data = []
for _ in range(int(sys.stdin.readline())):
command = list(sys.stdin.readline().split())
if len(command) == 2:
oper = command[0]
x = int(command[-1])
else:
oper = command[0]
if oper == "add":
if x not in data:
data.append(x)
elif oper == "remove":
if x in data:
data.remove(x)
elif oper == "check":
if x not in data:
print(0)
else:
print(1)
elif oper == "toggle":
if x not in data:
data.append(x)
else:
data.remove(x)
elif oper == "all":
data = [i for i in range(1, 21)]
elif oper == "empty":
data = []
ํด์ค
๊ฐ๋จํ ๋ฌธ์ !
'๐ Problem Solving > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค-17219] ๋น๋ฐ๋ฒํธ ์ฐพ๊ธฐ / Python (0) | 2021.05.28 |
---|---|
[๋ฐฑ์ค-16928] ๋ฑ๊ณผ ์ฌ๋ค๋ฆฌ ๊ฒ์ (0) | 2021.05.28 |
[๋ฐฑ์ค-11659] ๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ4 / Python (0) | 2021.05.27 |
[๋ฐฑ์ค-11286] ์ ๋๊ฐ ํ / Python (0) | 2021.05.27 |
[๋ฐฑ์ค-9461] ํ๋๋ฐ ์์ด / Python (0) | 2021.05.27 |