-
Notifications
You must be signed in to change notification settings - Fork 0
/
1065_single.cpp
84 lines (80 loc) · 1.5 KB
/
1065_single.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct people
{
int demo;
int flag1;
}Peo;
int main()
{
int num,all_num;
cin>>num;
Peo marry[num][2];
vector<int> dog;
for(int i=0;i<num;i++)
{
cin>>marry[i][0].demo>>marry[i][1].demo;
}
cin>>all_num;
int flag[all_num];
for(auto x:flag)
{
x=0;
}
int det[all_num];
for(int i=0;i<num;i++)
{
for(int k=0;k<2;k++)
{
marry[i][k].flag1=0;
}
}
for(int i=0;i<all_num;i++)
{
cin>>det[i];
flag[i]=0;
for(int j=0;j<num;j++)
{
for(int k=0;k<2;k++)
{
if(det[i]==marry[j][k].demo)
{
flag[i]=1;
marry[j][k].flag1=1;
}
}
}
}
for(int i=0;i<all_num;i++)
{
if(flag[i]==0)
{
dog.push_back(det[i]);
}
}
for(int i=0;i<num;i++)
{
if(marry[i][0].flag1==1)
{
if(marry[i][1].flag1!=1)
{
dog.push_back(marry[i][0].demo);
}
}
else if(marry[i][1].flag1==1)
{
dog.push_back(marry[i][1].demo);
}
}
sort(dog.begin(),dog.end(),less<int>());
for(vector<int>::iterator x=dog.begin();x<dog.end();x++)
{
cout<<*x;
if(x!=(dog.end()-1))
{
cout<<" ";
}
}
}