Two rows of numbers

You have 2n different numbers. Write a program to find all the ways to
put the numbers in two rows x₁…x_(n) and y₁…y_(n) so that:

- x₁ < x₂ < … < x_(n − 1) < x_(n) ,

- y₁ < y₂ < … < y_(n − 1) < y_(n) ,

- for every i, it holds x_(i) < y_(i).

Input

Input consists of n, followed by 2n different integer numbers. Assume
1 ≤ n ≤ 11.

Output

Print all the ways to put the numbers fulfilling the required
conditions. For every way, print three lines: two rows with x_(i) and
y_(i) separated by spaces, and an empty line. Print the solutions in
lexicographical order: first, those with the smaller x₁, in case of a
tie, those with the smaller x₂, …, in case of a tie, those with the
smaller x_(n), in case of a tie, those with the smaller y₁, …

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:00:39.323Z

© Jutge.org, 2006–2026.
https://jutge.org
