#C13398. Powerset Generation

    ID: 42931 Type: Default 1000ms 256MiB

Powerset Generation

Powerset Generation

Given a set of n distinct integers, your task is to generate its powerset, i.e. the set of all possible subsets. In mathematical terms, for a set \( S \) with \( n \) elements, the powerset \( \mathcal{P}(S) \) contains \( 2^n \) subsets including the empty set and \( S \) itself.

You are required to print the subsets in the order of increasing bitmask value. For each subset, the integers must appear in the same order as in the input. If a subset is empty, print an empty line.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains an integer \( n \) (where \( n \geq 1 \)).
  • The second line contains \( n \) space-separated integers representing the elements of the set.

outputFormat

Output to standard output (stdout) exactly \( 2^n \) lines. Each line represents one subset of the input set, printed as the space-separated integers in that subset (in the original order). If a subset is empty, output an empty line.

## sample
1
1

1

</p>