#C4807. Intersection of Two Arrays

    ID: 48386 Type: Default 1000ms 256MiB

Intersection of Two Arrays

Intersection of Two Arrays

Given two lists of integers, your task is to compute the unique intersection of the two lists and output the result in sorted order. The intersection of two sets \(A\) and \(B\) is defined as \(A \cap B = \{ x : x \in A \text{ and } x \in B \}\). For example, if the first list is [1, 2, 2, 1] and the second list is [2, 2], then the unique intersection is [2].

Please note that the input will be provided via standard input (stdin) as two separate lines. The first line contains the elements of the first list (space-separated integers) and the second line contains the elements of the second list (space-separated integers). Your output should be the sorted unique intersection printed to standard output (stdout) with each number separated by a single space. If there is no intersection, output an empty line.

inputFormat

The input consists of two lines:

  1. The first line contains space-separated integers representing the first array.
  2. The second line contains space-separated integers representing the second array.

outputFormat

Output a single line containing the sorted unique intersection of the two arrays. Numbers should be printed separated by a single space. If there is no common element, print an empty line.

## sample
1 2 2 1
2 2
2