Permutation Arrangement

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

You are given an array aa of length NN. Each element of aa is either -1 or an integer between 11 and NN. Each number between 11 and NN appears at most once in aa. Also, no two adjacent elements of aa have a difference of 11.

You are to find the lexicographically smallest permutation pp of 1,2,,N\\{1,2,\cdots ,N\\} satisfying the following.

  • If a_i1a\_i\neq -1, then a_i=p_ia\_i=p\_i (1iN1\leq i\leq N)
  • p_ip_i+11|p\_i-p\_{i+1}|\neq 1 (1iN11\leq i\leq N-1)

입력

The first line contains one integer, NN.

The second line contains space-separated NN integers — elements of the array aa.

출력

If there is no permutation pp satisfying the condition, then output a single integer 1-1.

Otherwise, output the lexicographically smallest permutation pp.

제한

  • 1N200,0001\leq N\leq 200,000
  • 1a_iN1\le a\_i\le N or a_i=1a\_i=-1 (1iN1\leq i\leq N)
  • a_ia_ja\_i\neq a\_j or a_i=1a\_i=-1 (1i\<jN1\leq i\<j\leq N)
  • a_ia_i+11|a\_i-a\_{i+1}|\neq 1 (1iN11\leq i\leq N-1)