-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1065.cpp
66 lines (61 loc) · 1019 Bytes
/
1065.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
bool attend_find(vector<int> attend,int p)
{
for(int i=0;i<attend.size();i++)
{
if(attend[i]==p)
return true;
}
return false;
}
int main()
{
int n;
cin>>n;
int parter[100010]={-1};
for(int i=0;i<n;i++)
{
int tmp1;
int tmp2;
cin>>tmp1>>tmp2;
parter[tmp1]=tmp2;
parter[tmp2]=tmp1;
}
int m;
cin>>m;
vector<int> attend(m);
for(int i=0;i<m;i++)
{
cin>>attend[i];
}
vector<int> res;
for(int i=0;i<m;i++)
{
if(parter[attend[i]]==-1)
res.push_back(attend[i]);
else
{
if(!attend_find(attend,parter[attend[i]]))
{
res.push_back(attend[i]);
}
}
}
sort(res.begin(),res.end());
cout<<res.size()<<endl;
if(res.size()>0)
{
for(int i=0;i<res.size()-1;i++)
{
printf("%05d",res[i]);
printf(" ");
}
printf("%05d\n",res[res.size()-1]);
}
return 0;
}