BOJ - 1620 - 나는야 포켓몬 마스터 이다솜
Updated:
import sys
def solution():
N, M = map(int, input().split())
idx = 1
pokemon_dict1 = {}
pokemon_dict2 = {}
for _ in range(N):
name = str(sys.stdin.readline()).strip()
pokemon_dict1[idx] = name
pokemon_dict2[name] = idx
idx += 1
for _ in range(M):
pokemon = str(sys.stdin.readline()).strip()
try:
print(pokemon_dict1[int(pokemon)])
except:
print(pokemon_dict2[pokemon])
solution()
https://www.acmicpc.net/problem/1620
Leave a comment