#include<iostream>
#include<map>
#include<set>
using namespace std;
map<int, int> C;
set<int> S1, S2;
int M[10010];
int main(){
int n, m;
scanf("%d", &n);
for(int i = 0;i < n; i++){
int a, b;
scanf("%d %d", &a, &b);
C[a] = b;
C[b] = a;
}
scanf("%d", &m);
for(int i = 0; i < m; i++){
int c;
scanf("%d", &c);
M[i] = c;
S1.insert(c);
}
for(int i = 0; i < m; i++){
if(S1.find(C[M[i]]) == S1.end()) S2.insert(M[i]);
}
printf("%d\n", S2.size());
for(auto it = S2.begin(); it != S2.end(); it++){
if(it != S2.begin()) printf(" ");
printf("%05d", *it);
}
return 0;
}
原文:https://www.cnblogs.com/tsruixi/p/13051534.html