416. Optimal Dartboard

Time limit per test: 0.25 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard

A dartboard is a disc divided into n segments, with each segment labeled with a distinct positive integer between 1 and n. That integer indicates the score for hitting the segment. To make the game more interesting, the arrangement of numbers is chosen in such a way that the risk is maximized. The risk is estimated based on the differences in scores of adjacent segments.

We're studying the following 'double-layered' structure of segments in this problem:

I.e., n is always even, and we split the disc into two layers of parts along the circumference. We enumerate the segments in the following manner: the first segment is some outer segment, the second segment is the corresponding inner segment, the third segment is some adjacent outer segment, etc. An example of this enumeration is shown on the picture above.

The total risk is defined as the sum of squared differences between the scores of adjacent segments. If the value assigned to segment i is ai, then the risk is:


(we assume an+1=a1 and an+2=a2 in this formula).

You are to place the numbers from 1 through n into the segments in such a way that the total risk R is maximized.

The input file contains an even integer number n (6 ≤ n ≤ 100).

Output n integer numbers: a1, a2,..., an, separated with single spaces. In case there are several possible solutions, output any.

sample input
sample output
2 9 7 4 6 5 3 8 10 1

Online Contester Team © 2002 - 2010. All rights reserved.