[C++] 백준 17219 : 비밀번호 찾기

Kim Nahyeong·2022년 3월 10일
0

백준

목록 보기
94/157

#include <iostream>
#include <map>
using namespace std;

int N, M;
map<string, string> m;
string str, str1, str2;
int main(int argc, char** argv){
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> N >> M;

  for(int i=0; i<N; i++){
    cin >> str1 >> str2;
    m.insert({str1, str2});
  }

  for(int i=0; i<M; i++){
    cin >> str;
    cout << m[str] << "\n";
  }

  return 0;
}

백준 1620 문제와 유사한 문제. 덕분에 금방 풀 수 있었다.
동일하게 map을 사용해 볼 수 있었고 연습하는 문제가 되었다.

0개의 댓글