#K72187. Unique Elements Finder

    ID: 33698 Type: Default 1000ms 256MiB

Unique Elements Finder

Unique Elements Finder

You are given two lists of integers. Your task is to find all the elements that are unique to each list—i.e. the elements that appear in one list but not in the other. The resulting list should be sorted in increasing order.

Mathematically, if we denote the two sets as \(A\) and \(B\), you need to compute the sorted list corresponding to the set:

$$ (A \setminus B) \cup (B \setminus A) $$

For example, if \(A=[1,2,3]\) and \(B=[3,4,5]\), then the answer is \([1,2,4,5]\).

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains a sequence of integers separated by spaces representing the first list. This line may be empty, indicating an empty list.
  • The second line contains a sequence of integers separated by spaces representing the second list. This line may also be empty.

outputFormat

Print to standard output (stdout) a single line containing the sorted unique elements separated by a single space. If there are no unique elements, print an empty line.

## sample
1 2 3
3 4 5
1 2 4 5