#C1603. Subsets Without Duplicates
Subsets Without Duplicates
Subsets Without Duplicates
Given a list of integers, your task is to generate the power set (all possible subsets) of the list after removing any duplicate values. The unique elements should be sorted in ascending order, and the subsets must be output in order of increasing subset size. For each subset, the elements must appear in the same order as in the sorted unique list.
Input Format:
- The first line contains an integer n, representing the number of elements in the list.
- If n > 0, the second line contains n integers separated by spaces.
Output Format:
- Print each subset on a separate line.
- Within each subset, print the numbers separated by a single space. For an empty subset, print an empty line.
Note: The order of the output subsets is defined by first increasing the number of elements in the subset, and for subsets of the same size, by lexicographical order based on the sorted unique list.
The LaTeX representation of the combinatorial selection is given by: $$C(n, k)=\frac{n!}{k!(n-k)!}.$$
inputFormat
The input consists of two lines:
- The first line contains a single integer n, the number of elements.
- If n > 0, the second line contains n space-separated integers.
outputFormat
Output all unique subsets (power set) in ascending order by subset size. Each subset should be printed on a new line, with its elements separated by a single space. An empty subset should result in an empty line.
## sample3
1 2 3
1
2
3
1 2
1 3
2 3
1 2 3
</p>