Sequences with no wells X41088


Statement
 

pdf   zip

html

A sequence of numbers has a well if it contains three consecutive numbers such that that the endpoints add up more than twice the one in the middle.

Formally, (x1, x2 , … , xn) has a well if it exists at least an i with 1 ≤ i < n − 1 such that xi + xi+2 > 2· xi+1.

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

Input

The input consists of an integer n ≥ 1.

Output

Write all sequences with no well that can be obtained by reordering the sequence (1, 2, …, n). You can write the sequences in any order.

Public test cases
  • Input

    3
    
    

    Output

    (1,2,3)
    (1,3,2)
    (2,3,1)
    (3,2,1)
    
  • Input

    2
    
    

    Output

    (1,2)
    (2,1)
    
  • Input

    4
    
    

    Output

    (1,2,3,4)
    (1,3,4,2)
    (1,4,3,2)
    (2,3,4,1)
    (2,4,3,1)
    (4,3,2,1)
    
  • Input

    1
    

    Output

    (1)
    
  • Information
    Author
    Language
    English
    Translator
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python