====== 나는야 포켓몬 마스터 이다솜 ====== ===== 풀이 ===== * 이름으로부터 번호를 매핑하는 dict를 만들어서 처리하면 된다. 총 시간복잡도는 O(n+m) ===== 코드 ===== """Solution code for "BOJ 1620. 나는야 포켓몬 마스터 이다솜". - Problem link: https://www.acmicpc.net/problem/1620 - Solution link: http://www.teferi.net/ps/problems/boj/1620 """ import sys def main(): N, M = [int(x) for x in sys.stdin.readline().split()] pokemons = [sys.stdin.readline().rstrip() for _ in range(N)] num_by_pokemon = {x: i for i, x in enumerate(pokemons, start=1)} for _ in range(M): inp = sys.stdin.readline().rstrip() if inp.isdigit(): print(pokemons[int(inp) - 1]) else: print(num_by_pokemon[inp]) if __name__ == '__main__': main() {{tag>BOJ ps:problems:boj:실버_4}}