각 i에서 T(i)까지의 원형 거리가 주어질 때, 이를 만족하는 순열 T 중 사전순으로 가장 작은 것을 구하거나 존재하지 않음을 판정한다.
어려움8그리디백트래킹그래프구현면접 대비아직 제출이 없습니다시간 제한1초메모리 제한512 MBFor 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{|x − y|, N − |x − y|}. 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