hdu 1412 {A} + {B}

时间:2023-03-10 04:21:46
hdu 1412 {A} + {B}

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=3282

{A} + {B}

Description

给你两个集合,要求{A} + {B}.
注:同一个集合中不会有两个相同的元素.

Input

每组输入数据分为三行,第一行有两个数字$n,m(0 < n,m \leq 10000)$,分别表示集合A和集合B的元素个数.后两行分别表示集合A和集合B.每个元素为不超出int范围的整数,每个元素之间有一个空格隔开.

Output

针对每组数据输出一行数据,表示合并后的集合,要求从小到大输出,每个元素之间有一个空格隔开.

SampleInput

1 2
1
2 3
1 2
1
1 2

SampleOutput

1 2 3
1 2

 #include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
using std::cin;
using std::cout;
using std::endl;
using std::find;
using std::sort;
using std::set;
using std::map;
using std::pair;
using std::vector;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define iter(c) decltype((c).begin())
#define cls(arr,val) memset(arr,val,sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
const int Max_N = ;
typedef unsigned long long ull;
set<int> res;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int n, m, v;
while (~scanf("%d %d", &n, &m)) {
rep(i, n + m) scanf("%d", &v), res.insert(v);
iter(res) it = res.begin();
printf("%d", *it++);
for (; it != res.end(); ++it) printf(" %d", *it);
putchar('\n');
res.clear();
}
return ;
}