#C12849. Find Common Unique Elements
Find Common Unique Elements
Find Common Unique Elements
You are given two lists of integers. Your task is to find all the common elements between the two lists, remove any duplicates, and output them in ascending order. More formally, given two lists (A) and (B), you need to compute (\text{result} = \mathrm{sorted}({ x \mid x \in A \text{ and } x \in B })). If there are no common elements, output an empty line.
inputFormat
The input is read from standard input and consists of four lines:
- The first line contains an integer (n), the number of elements in the first list.
- The second line contains (n) space-separated integers representing the first list.
- The third line contains an integer (m), the number of elements in the second list.
- The fourth line contains (m) space-separated integers representing the second list.
outputFormat
Print the common unique elements in ascending order, separated by a single space. If there are no common elements, print an empty line.## sample
6
1 2 3 4 4 5
6
3 4 4 5 6 7
3 4 5