온라인저지
[BOJ] 1764번: 듣보잡
plzfday
2018. 7. 26. 23:54
https://www.acmicpc.net/problem/1764
정말 듣도보도 못한 문제다. 그 문자열이 두 번 나오면 듣보잡이다.
#include <bits/stdc++.h>
using namespace std;
struct Info
{
int count;
};
int main()
{
ios_base::sync_with_stdio(false), cin.tie(0);
int N, M;
cin >> N >> M;
map<string, Info> ms;
for (int i = 0; i < (N + M); ++i)
{
string tmp;
cin >> tmp;
ms.insert(make_pair(tmp, Info()));
ms[tmp].count++;
}
vector<string> v;
for (auto &i : ms)
if (i.second.count >= 2)
v.push_back(i.first);
sort(v.begin(), v.end());
cout << v.size() << '\n';
for (auto &i : v)
cout << i << '\n';
return 0;
}