254일차 - BOJ no.1620

https://www.acmicpc.net/problem/1620

My Solution

import sys

N, M = map(int, sys.stdin.readline().rstrip().split())

pokemon = {}
for i in range(1, N + 1):
    x = sys.stdin.readline().rstrip()
    pokemon[i] = x
    pokemon[x] = i


command = []
for _ in range(M):
    command.append(sys.stdin.readline().rstrip())

for i in command:
    if i.isdigit():
        print(pokemon[int(i)])
    else:
        print(pokemon[i])

좋은 웹페이지 즐겨찾기