-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path210122_BOJ_1764.cpp
More file actions
55 lines (42 loc) · 825 Bytes
/
Copy path210122_BOJ_1764.cpp
File metadata and controls
55 lines (42 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
int N = 0;
int M = 0;
cin >> N >> M;
map<string, int> m;
vector<string> v;
int cnt = 0;
for (int i = 0; i < N + M; ++i) {
string temp; cin >> temp;
auto findPeople = m.find(temp);
if (findPeople == m.end()) {
m.insert({ temp, 1 });
}
else {
m[temp]++;
if (m[temp] >= 2) {
cnt++;
//v.push_back(temp);
}
}
}
cout << cnt << "\n";
for (auto it = m.begin(); it != m.end(); ++it) {
if (it->second >= 2)
cout << it->first << "\n";
}
/*sort(v.begin(), v.end());
cout << v.size() << "\n";
for (int i = 0; i < v.size(); ++i) {
cout << v[i] << "\n";
}
cout << "\n";*/
return 0;
}