No wells

A sequence of numbers has a well if it contains three consecutive
numbers such that the endpoints add up more than twice the one in the
middle. Formally, (x₁, x₂, …, x_(n)) has a well if it exists at least an
i with 2 ≤ i ≤ n − 1 such that x_(i − 1) + x_(i + 1) > 2x_(i).

Write a program that, given an integer n, prints all the sequences with
no wells that can be obtained by reordering the sequence (1, 2, …, n).

Input

Input consists of several cases, each one with an n between 1 and 10⁵.

Output

For every n, print all the permutations with no wells in lexicographical
order. Print a line with 10 dashes at the end of every case.

Problem information

Author: Albert Oliveras

Generation: 2026-01-25T11:13:59.192Z

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