728x90
반응형
17219 번 비밀번호 찾기
문제풀이
#include <iostream>
#include <string.h>
#include <map>
#include <sstream>
using namespace std;
void fast_io(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
string c, d;
int main(void)
{
fast_io();
map<string, string> m;
int a, b;
cin >> a >> b;
cin.ignore();
while (a--)
{
string all;
getline(cin, all);
stringstream ss(all);
ss >> c >> d;
m.insert(make_pair(c, d));
}
while (b--)
{
cin >> c;
cout << m.find(c)->second << "\n";
}
}
원래 stringstream 을 안쓰고 했는데 써봤다.
받은string을 공백이나 개행단위로 끊어서 ss에 저장하고
c 와 d 로 넘겨주었다.
728x90
반응형
'자라는 개발자 > 문제풀이' 카테고리의 다른 글
백준 c++ 23841번 데칼코마니 (1) | 2022.01.06 |
---|---|
백준 C++ 10809 알파벳 찾기 (0) | 2022.01.05 |
백준 c++ 1620 나는야 포켓몬 마스터 이다솜 (1) | 2022.01.02 |
백준 C++/C 2577번 숫자의 개수 (1) | 2021.12.27 |
백준 C++ 1764번 듣보잡 (1) | 2021.12.26 |