-->
当前位置:首页 > 题库

PROGRAMMING:Intersection and union of sets

Luz5年前 (2021-05-10)题库450
Two sets of numbers are given, and the intersection and union of the two sets are requested.
###Input format:
Let N and M denote the size of two sequences * * (0 < = n, m < = 2e5)**
If n > 0, the next line is separated by N spaces, representing the number in the first set.
If M > 0, the next row is separated by M spaces, representing the number in the second set.
-1e9<=ai,bi<=1e9
###Output format:
The first row outputs the number of elements in the set where two sequences intersect. If the number of elements is greater than 0, then the elements of the "intersection" are output in this row and arranged in ascending order of numerical value * * (when multiple data are output in this row, separate them with spaces. If there is only one element number, there is no space at the end of the row)**
In the second row, the number of elements in the set of two series is output first. If the number of elements is greater than 0, then the elements of "union" are output in this row and arranged in ascending order of numerical value * * (when multiple data are output in this row, space is used to separate them. If there is only one element, there is no space at the end of the row)**
###Input sample 1:
```in
1 3
one
1 3 4
```
###Output sample 1:
```out
1 1
3 1 3 4
```
###Input sample 2:
```in
1 3
one
2 3 4
```
###Output sample 2:
```out
0
4 1 2 3 4
```






answer:If there is no answer, please comment