#C10167. Zigzag Sequence

    ID: 39342 Type: Default 1000ms 256MiB

Zigzag Sequence

Zigzag Sequence

Given an integer n, determine if it is possible to construct a zigzag sequence of n distinct positive integers. A zigzag sequence is formed by alternately taking the smallest and the largest remaining numbers until the sequence is complete. If such a sequence exists, output one valid sequence; otherwise, output impossible.

For example, when n = 1, the only sequence is 1. When n = 2 or n = 4, no valid zigzag sequence exists. When n = 5, one valid sequence is 1 5 2 4 3.

The construction can be understood as follows: For n > 1, pair the smallest number i with the largest remaining number n-i+1 for i from 1 to \lfloor n/2 \rfloor, and if n is odd, append the middle number \lfloor n/2 \rfloor+1 at the end.

inputFormat

The input consists of a single integer n (1 \le n \le 10^5), read from standard input.

outputFormat

If a zigzag sequence exists, output the sequence as space-separated integers in one line to standard output. Otherwise, output impossible.

## sample
1
1

</p>