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

8120번 - Coding of Permutations 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB1981168959.732%

문제

Every permutation A = (a1, ..., an) of numbers 1, ..., n can be coded by a sequence B = (b1, ..., bn) in which bi equals the number of all aj such that (j < i & aj > ai), for i = 1, ..., n.

The sequence B = (0, 0, 1, 0, 2, 0, 4) is the code of the permutation A = (1, 5, 2, 6, 4, 7, 3).

Write a program that:

  • reads from the standard input the length n and successive elements of the sequence B,
  • examines whether it is a code of some permutation of numbers 1, ..., n,
  • if so, it finds that permutation and writes it in the standard output,
  • otherwise it writes in the standard output one word NIE ("no").

입력

  • In the first line of the standard input there is a positive integer n ≤ 30,000. It is the number of elements of the sequence B.
  • In each of the following n lines there is one nonnegative integer not greater than 30,000. It is the successive element of the sequence B.

출력

The standard output should contain:

  • in each of n consecutive lines - one element of the permutation A, whose code is the sequence B written in the standard input,
  • one word NIE, if the sequence B is not a code of any permutation.

제한

예제 입력 1

7
0
0
1
0
2
0
4

예제 출력 1

1
5
2
6
4
7
3

예제 입력 2

4
0
2
0
0

예제 출력 2

NIE

힌트

출처

Olympiad > Polish Olympiad in Informatics > POI 1994/1995 > Stage 3 1번

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

출처

대학교 대회

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

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