[백준] 1620 나는야 포켓몬 마스터 이다솜

김은서·2021년 10월 6일
0

백준

목록 보기
36/48

Python Code

import sys
N, M = map(int, input().split())
name_dict = {}
num_dict = {}
num = 1
for _ in range(N):
    name = str(sys.stdin.readline()).strip()
    name_dict[num] = name
    num_dict[name] = num
    num += 1
for _ in range(M):
    problem = str(sys.stdin.readline()).strip()
    try:
        print(name_dict[int(problem)])
    except:
        print(num_dict[problem])
profile
Gracelog

0개의 댓글