-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet_Union.cpp
More file actions
48 lines (40 loc) · 786 Bytes
/
Copy pathSet_Union.cpp
File metadata and controls
48 lines (40 loc) · 786 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
40
41
42
43
44
45
46
47
48
#include<bits/stdc++.h>
using namespace std;
int main()
{
bool unique[1001] = {0};
int N[1000], M[1000], n, m;
int result[1000], p=0;
cin >> n >> m;
for(int i=0; i<n; i++)
{
cin >> N[i];
if(unique[N[i]] == 0)
{
unique[N[i]] = 1;
result[p] = N[i];
p++;
}
}
for(int i=0; i<m; i++)
{
cin >> M[i];
if(unique[M[i]] == 0)
{
unique[M[i]] = 1;
result[p] = M[i];
p++;
}
}
sort(result, result + p);
for(int i=0; i<p; i++)
{
cout << result[i];
if(i<p-1)
{
cout << " ";
}
}
cout << endl;
return 0;
}