문제
풀이
map 자료구조를 사용해 풀면된다.
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
int n, m;
int cnt = 0;
map<string, bool> mp;
cin >> n >> m;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
mp.insert({ s, true });
}
for (int i = 0; i < m; i++) {
string s;
cin >> s;
if (mp[s] == true) cnt++;
}
cout << cnt;
return 0;
}
'백준 > 집합과 맵' 카테고리의 다른 글
1764번: 듣보잡 [C++] (0) | 2023.03.31 |
---|---|
10816번: 숫자 카드 2 [C++] (0) | 2023.03.31 |
1620번: 나는야 포켓몬 마스터 이다솜 [C++] (0) | 2023.03.31 |
10815번: 숫자 카드 [C++] (0) | 2023.03.31 |