해쉬맵을 이용하여 숫자와 문자열을 연결했다.
포켓몬 스토리 읽는 재미가 있었다 ㅎㅎ
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine()," ");
StringBuilder sb = new StringBuilder();
int N=Integer.parseInt(st.nextToken());
int M=Integer.parseInt(st.nextToken());
Map<String,String> map = new HashMap<>();
String str;
for(int i=1; i<=N; i++) {
str = br.readLine();
map.put(Integer.toString(i), str);
map.put(str, Integer.toString(i));
}
for(int i=1; i<=M; i++) {
str = br.readLine();
sb.append(map.get(str)+"\n");
}
System.out.print(sb);
br.close();
}
}