#B3632. Set Operations on Integer Sets

    ID: 11292 Type: Default 1000ms 256MiB

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:

  1. \(|A|\) — the number of elements in set A
  2. \(A \cap B\) — the intersection of sets A and B
  3. \(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:

  1. The first line is \(|A|\), the number of distinct integers in set A.
  2. 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.
  3. 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>