-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1764.cpp
More file actions
33 lines (28 loc) · 693 Bytes
/
1764.cpp
File metadata and controls
33 lines (28 loc) · 693 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
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define io ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main()
{
io;
int N,M;
cin>>N>>M;
map<string,int> noListenMap;
vector<string> noListen(N+1);
vector<string> noSee(M+1);
vector<string> res;
for(int i=1;i<=N;i++) {
cin>>noListen[i];
noListenMap.insert({noListen[i],i});
}
for(int i=1;i<=M;i++) cin>>noSee[i];
for(int i=1;i<=M;i++){
if(noListen[noListenMap[noSee[i]]]==noSee[i]) res.push_back(noSee[i]);
}
sort(res.begin(),res.end());
cout<<res.size()<<'\n';
for(string s:res)cout<<s<<'\n';
return 0;
}