#abc349g. G - Palindrome Construction

G - Palindrome Construction

Score: 625625 points

问题陈述

一个正整数序列 T=(T1,T2,,TM)T=(T_1,T_2,\dots,T_M) 的长度为 MM,如果且仅如果对于每个 i=1,2,,Mi=1,2,\dots,M,都有 Ti=TMi+1T_i=T_{M-i+1},则称其为一个回文序列

给定一个非负整数序列 A=(A1,A2,,AN)A = (A_1,A_2,\dots,A_N) 的长度为 NN。确定是否存在一个正整数序列 S=(S1,S2,,SN)S=(S_1,S_2,\dots,S_N) 的长度为 NN,满足以下条件,如果存在,找到字典序最小的这样一个序列。

  • 对于每个 i=1,2,,Ni=1,2,\dots,N,以下两个条件都成立:
    • 序列 (SiAi,SiAi+1,,Si+Ai)(S_{i-A_i},S_{i-A_i+1},\dots,S_{i+A_i}) 是一个回文序列。
    • 如果 2iAi2 \leq i-A_ii+AiN1i+A_i \leq N-1,序列 (SiAi1,SiAi,,Si+Ai+1)(S_{i-A_i-1},S_{i-A_i},\dots,S_{i+A_i+1}) 不是一个回文序列。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

A sequence of positive integers T=(T1,T2,,TM)T=(T_1,T_2,\dots,T_M) of length MM is a palindrome if and only if Ti=TMi+1T_i=T_{M-i+1} for each i=1,2,,Mi=1,2,\dots,M.

You are given a sequence of non-negative integers A=(A1,A2,,AN)A = (A_1,A_2,\dots,A_N) of length NN. Determine if there is a sequence of positive integers S=(S1,S2,,SN)S=(S_1,S_2,\dots,S_N) of length NN that satisfies the following condition, and if it exists, find the lexicographically smallest such sequence.

  • For each i=1,2,,Ni=1,2,\dots,N, both of the following hold:
    • The sequence (SiAi,SiAi+1,,Si+Ai)(S_{i-A_i},S_{i-A_i+1},\dots,S_{i+A_i}) is a palindrome.
    • If 2iAi2 \leq i-A_i and i+AiN1i+A_i \leq N-1, the sequence (SiAi1,SiAi,,Si+Ai+1)(S_{i-A_i-1},S_{i-A_i},\dots,S_{i+A_i+1}) is not a palindrome.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 0Aimin{i1,Ni}0 \leq A_i \leq \min\{i-1,N-i\}
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \dots ANA_N

Output

If there is no sequence SS that satisfies the condition, print No.

If there is a sequence SS that satisfies the condition, let SS' be the lexicographically smallest such sequence and print it in the following format:

Yes

S1S'_1 S2S'_2 \dots SNS'_N

Sample Input 1

7
0 0 2 0 2 0 0

Sample Output 1

Yes
1 1 2 1 1 1 2

S=(1,1,2,1,1,1,2)S = (1,1,2,1,1,1,2) satisfies the condition:

  • i=1i=1: (A1)=(1)(A_1)=(1) is a palindrome.
  • i=2i=2: (A2)=(1)(A_2)=(1) is a palindrome, but (A1,A2,A3)=(1,1,2)(A_1,A_2,A_3)=(1,1,2) is not.
  • i=3i=3: (A1,A2,,A5)=(1,1,2,1,1)(A_1,A_2,\dots,A_5)=(1,1,2,1,1) is a palindrome.
  • i=4i=4: (A4)=(1)(A_4)=(1) is a palindrome, but (A3,A4,A5)=(2,1,1)(A_3,A_4,A_5)=(2,1,1) is not.
  • i=5i=5: (A3,A4,,A7)=(2,1,1,1,2)(A_3,A_4,\dots,A_7)=(2,1,1,1,2) is a palindrome.
  • i=6i=6: (A6)=(1)(A_6)=(1) is a palindrome, but (A5,A6,A7)=(1,1,2)(A_5,A_6,A_7)=(1,1,2) is not.
  • i=7i=7: (A7)=(2)(A_7)=(2) is a palindrome.

There are other sequences like S=(2,2,1,2,2,2,1)S=(2,2,1,2,2,2,1) that satisfy the condition, but print the lexicographically smallest one, which is (1,1,2,1,1,1,2)(1,1,2,1,1,1,2).

Sample Input 2

7
0 1 2 3 2 1 0

Sample Output 2

Yes
1 1 1 1 1 1 1

Sample Input 3

7
0 1 2 0 2 1 0

Sample Output 3

No