-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_1065.cpp
More file actions
39 lines (39 loc) · 704 Bytes
/
Copy pathB_1065.cpp
File metadata and controls
39 lines (39 loc) · 704 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
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
const int maxn = 1000000;
int couple[maxn] = {-1}, guest[maxn] = {-1};
int isExist[maxn] = {0};
int main()
{
int n, m, c1, c2;
set<int> s;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%d%d", &c1, &c2);
couple[c1] = c2;
couple[c2] = c1;
}
scanf("%d", &m);
for(int i = 0; i < m; i++)
{
scanf("%d", &guest[i]);
if(couple[guest[i]] != -1)
isExist[couple[guest[i]]] = 1;
}
for(int i = 0; i < m; i++)
{
if(!isExist[guest[i]])
s.insert(guest[i]);
}
printf("%d\n", s.size());
for(auto it = s.begin(); it != s.end(); it++)
{
if(it != s.begin())
printf(" ");
printf("%d", *it);
}
return 0;
}