### National Olympiad in Informatics, China, 2009

## Day 1, Problem 1 - Transformed Sequence

For `N` integers 0, 1, …, `N`−1, a transformed sequence `T` can change `i` to `T _{i}`, where

`T`∈ {0, 1, …,

_{i}`N`−1} and ∪

_{i = 0}

^{N−1}{

`T`} = {0, 1, …,

_{i}`N`−1}. ∀

`x`,

`y`∈ {0, 1, …,

`N`−1}, define the distance between

`x`and

`y`to be

`D`(

`x`,

`y`) = min{|

`x`−

`y`|,

`N`− |

`x`−

`y`|}. Given the distance

`D`(

`i`,

`T`) between each

_{i}`i`and

`T`, you must determine a transformed sequence

_{i}`T`that satisfy the requirements. If many sequences satisfy the requirements, then output the lexicographically smallest one.

** Note:** For two transformed sequences

`S`and

`T`, if there exists a

`p`<

`N`that satisfies

`S`=

_{i}`T`and

_{i}`S`<

_{p}`T`for

_{p}`i`= 0, 1, …,

`p`−1, then we say that

`S`is lexicographically smaller than

`T`.

### Input Format

The first line of input contains a single integer `N`, the length of the sequence. The following line contains `N` integers `D _{i}`, where

`D`is the distance between

_{i}`i`and

`T`.

_{i}### Output Format

If there exists at least one transformed sequence `T`, then output one line containing `N` integers, representing the lexicographically smallest transformed sequence `T`. Otherwise, output "`No Answer`

" (without quotes). __Note: Pairs of adjacent numbers in the output must be separated by a single space, and there cannot be trailing spaces.__

### Sample Input

5 1 1 2 2 1

### Sample Output

1 2 4 0 3

### Constraints

For 20% of the test data, `N` ≤ 50.

For 60% of the test data, `N` ≤ 500.

For 100% of the test data, `N` ≤ 10000.

All Submissions

Best Solutions

**Point Value:** 20 (partial)

**Time Limit:** 1.00s

**Memory Limit:** 256M

**Added:** Aug 04, 2014

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

It's quiet in here...