https://www.acmicpc.net/problem/17219
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
int n,m;
unordered_map<string, string> um;
int main()
{
cin >> n >> m;
for(int i=0; i< n ;i++)
{
string add;
string pass;
cin >> add >> pass;
um.insert(make_pair(add,pass));
}
for(int i=0;i<m;i++)
{
string add;
cin >> add;
if(um.find(add)!=um.end())cout << um[add] << '\n';
}
}
바킹독님 풀이
// Authored by : heheHwang
// Co-authored by : -
// http://boj.kr/6dbb1711d18a41e48fa54edfcb93cc7c
#include
using namespace std;
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
int N, M;
string s, p;
unordered_map<string, string=""> umap;
cin >> N >> M;
while (N--) {
cin >> s >> p;
umap[s] = p;
}
while (M--) {
cin >> s;
cout << umap[s] << '\n';
}
}</string,>
'CS(Computer Science)지식 > [C++][코딩 테스트] 자료구조 및 알고리즘' 카테고리의 다른 글
백준 7662번: 이중 우선순위 큐 (C++) (0) | 2024.01.31 |
---|---|
백준 9375번: 패션왕 신해빈 [C++] (0) | 2024.01.31 |
백준 13414번: 수강신청 [C++] (0) | 2024.01.31 |
백준 1620번: 나는야 포켓몬 마스터 이다솜 [C++] (0) | 2024.01.31 |
백준 7785번: 회사에 있는 사람 [C++] (0) | 2024.01.31 |