#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(){
int n, m;
string a, b;
cin >> n;
vector <string> ans, t;
map<string, string> ma;
map<string, bool> mb;
for (int i = 0; i < n; i++) {
cin >> a >> b;
ma[a] = b;
ma[b] = a;
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> a;
t.push_back(a);
mb[a] = 1;
}
for (int i = 0; i < m; i++) {
if(!mb[ma[t[i]]]) ans.push_back(t[i]);
//ma[t[i]] t[i]的配偶 mb判断其是否出现在聚会中
}
sort(ans.begin(), ans.end());
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); i++) {
if(i != 0) cout << ' ';
cout << ans[i];
}
//呵呵哒
if (ans.size()) {
cout << endl;
}
return 0;
}
1121. Damn Single (25) 格式 map
最新推荐文章于 2021-10-13 20:40:31 发布