#B3632. Set Operations on Integer Sets
Set Operations on Integer Sets
Set Operations on Integer Sets
Given two sets A and B composed of integers within the range \(0 \leq x \leq 63\), compute the following:
- \(|A|\) — the number of elements in set A
- \(A \cap B\) — the intersection of sets A and B
- \(A \cup B\) — the union of sets A and B
Both the intersection and union outputs should list their elements in ascending order, separated by a single space. If a set is empty, output an empty line for that set.
inputFormat
The input consists of two lines:
- The first line contains the integers in set A separated by spaces.
- The second line contains the integers in set B separated by spaces.
outputFormat
Output exactly three lines:
- The first line is \(|A|\), the number of distinct integers in set A.
- The second line lists the elements of \(A \cap B\) in ascending order, separated by a single space. Print an empty line if the intersection is empty.
- The third line lists the elements of \(A \cup B\) in ascending order, separated by a single space.
sample
1 3 5
3 4 5
3
3 5
1 3 4 5
</p>