#C2097. Lexicographical Power Set

    ID: 45375 Type: Default 1000ms 256MiB

Lexicographical Power Set

Lexicographical Power Set

Given an array of distinct integers, your task is to generate its power set (i.e. all possible subsets) and output them in lexicographical order. Two subsets are compared lexicographically: for two subsets \( A \) and \( B \), if at the first index where they differ the element in \( A \) is less than that in \( B \), then \( A \) is considered to come before \( B \). If one subset is a prefix of another, the shorter subset comes first.

Note: The lexicographical order is defined based on the natural order of the integers. For example, for an input array \( [3, 1, 2] \), after sorting, the array becomes \( [1,2,3] \) and its power set in lexicographical order is:

[ [,],\ [1],\ [1,2],\ [1,2,3],\ [1,3],\ [2],\ [2,3],\ [3] ]

You are required to read the input from standard input (stdin) and output the result to standard output (stdout) exactly in the format as shown in the examples.

inputFormat

The input consists of a single line with space-separated integers representing the elements of the array. If the input line is empty, the array is considered empty.

outputFormat

Output the lexicographically sorted power set, where each subset is represented as a list. The overall output should be a list of lists, with the format exactly matching the examples (including spaces and commas).

## sample
3 1 2
[[], [1], [1, 2], [1, 2, 3], [1, 3], [2], [2, 3], [3]]