https://www.acmicpc.net/problem/1764
맵 하나만 써서 없으면 제거하고 남긴거 출력할까 하면서 remove delete 다써봤는데 .erase(key) 였다.
근데 그냥 맵 두 개 쓰는게 나아서 바꿨다. 공간은 많이 써도 된다는 점 유념하기!
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
map<string, bool> d;
map<string, bool> db;
int n, m, i;
string s;
cin >> n >> m;
for (i = 0; i < n; i++){
cin >> s;
d[s] = true;
}
for (i = 0; i < m; i++){
cin >> s;
if (d[s])
db[s] = true;
}
cout << db.size() << '\n';
for (auto it = db.begin(); it != db.end(); it++) {
cout << it->first << '\n';
}
return 0;
}```