본문 바로가기
코딩/cpp

[백준] 17219번

by 적막한숲 2025. 9. 25.

이 문제는 hash table이나 dict 같은 내용을 접목하면 쉽게 해결이 가능하다.

아니면 이차원 배열을 써야 하는데, 배열 변태가 목적이면 그렇게 해결하면 되겠지만, 나는 굳이 힘든 길을 가고 싶진 않다.

 

 

 

#include <unordered_map>
#include <iostream>
#include <string>

int main() {
    int n, m;
    std::cin >> n >> m;
    std::unordered_map<std::string, std::string> hash_dict;
    std::string word;
    for (int i = 0; i < n; i++) {
        word="";
        std::cin >> word >> hash_dict[word];
    }

    for (int i = 0; i < m; i++) {
        word = "";
        std::cin >> word;
        std::cout << hash_dict[word] << '\n';
    }
    return 0;
}

'코딩 > cpp' 카테고리의 다른 글

[백준] 1463번  (0) 2025.09.25
[백준] 1003번  (0) 2025.09.25
[백준] 11399번  (0) 2025.09.25
[백준] 11047번  (0) 2025.09.25
[백준] 14626번  (0) 2025.09.25