Notice
Recent Posts
Recent Comments
Link
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags
more
Archives
Today
Total
관리 메뉴

main

[백준-17219번/Java] 비밀번호 찾기 본문

Algorithm

[백준-17219번/Java] 비밀번호 찾기

1984 2022. 11. 16. 21:14

* Map 을 사용하여 풀었다.

 

import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int N = in.nextInt();
		int M = in.nextInt();

		HashMap<String, String> map = new HashMap<String, String>();

		for (int i = 0; i < N; i++) {
			String url = in.next();
			String pass = in.next();
			

			map.put(url, pass);
		}

		for (int i = 0; i < M; i++) {
			String url = in.next();
			bw.write(map.get(url) + "\n");
		}
		
		bw.flush();
	}

}
728x90
Comments