Logo
(追記) (追記ここまで)

17330번 - Transformed Sequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB942100.000%

문제

For N integers 0, 1, …, N−1, a transformed sequence T can change i to Ti, where Ti ∈ {0, 1, …, N−1} and ∪i = 0N−1 { Ti } = {0, 1, …, N−1}. ∀x, y ∈ {0, 1, …, N−1}, define the distance between x and y to be D(x, y) = min{|xy|, N − |xy|}. Given the distance D(i, Ti) between each i and Ti, you must determine a transformed sequence 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 Si = Ti and Sp < Tp for i = 0, 1, …, p−1, then we say that S is lexicographically smaller than T.

입력

The first line of input contains a single integer N, the length of the sequence.

The following line contains N integers Di, where Di is the distance between i and Ti.

출력

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.

제한

N ≤ 10000

예제 입력 1

5
1 1 2 2 1

예제 출력 1

1 2 4 0 3

힌트

출처

Olympiad > National Olympiad in Informatics (China) > NOI 2009 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /