-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathB1065.cpp
48 lines (46 loc) · 1.25 KB
/
B1065.cpp
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
/*************************************************************************
> File Name: B1065.cpp
> Author: bumzy
> Mail: [email protected]
> Created Time: 2017年07月30日 星期日 16时38分28秒
************************************************************************/
#include <stdio.h>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;
int main(void) {
int n, m;
unordered_map<int, int> couple;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int a, b;
scanf("%d%d", &a, &b);
couple[a] = b;
couple[b] = a;
}
scanf("%d", &m);
unordered_set<int> guest;
vector<int> single;
for (int i = 0; i < m; ++i) {
int id;
scanf("%d", &id);
guest.insert(id);
}
for(auto i = guest.begin(); i != guest.end(); ++i) {
if (couple.find(*i) == couple.end() ||
(guest.find(couple[*i]) == guest.end())) {
single.push_back(*i);
}
}
sort(single.begin(), single.end());
printf("%lu\n", single.size());
for (size_t i = 0; i < single.size(); ++i) {
printf("%05d", single[i]);
if (i < single.size() - 1) {
printf(" ");
}
}
return 0;
}