NOI Contest Archive

Archive / 2021 / November 2021

Housing Scheme

Medium · National Olympiad in Informatics Sri Lanka - November 2021

An engineer together with his architect is designing a scheme. The scheme has houses but it also has office buildings. All the buildings here are to be built next to each other such that they are approximately in a straight line.

The difference between the number of floors of any two adjacent buildings has to be greater than or equal to 2 and less than or equal to 4. The scheme always has two or more buildings. For any given number of buildings b in the scheme, find an arrangement of buildings that satisfies the above condition.

Each building is numbered from 1 to b based on the number of floors it has (If the building has only one floor the building is numbered as 1) and the number of floors in each building should be unique (That is for b number of buildings there can only be one bulding with one floor).

Input Format

Output Format

Constraints

Sample Input 0

8
3
10
4
22
11
9
15
8

Sample Output 0

-1
9 7 5 3 1 4 2 6 8 10 
3 1 4 2 
21 19 17 15 13 11 9 7 5 3 1 4 2 6 8 10 12 14 16 18 20 22 
11 9 7 5 3 1 4 2 6 8 10 
9 7 5 3 1 4 2 6 8 
15 13 11 9 7 5 3 1 4 2 6 8 10 12 14 
7 5 3 1 4 2 6 8