The year is 42XX, and the world is in ruins, a consequence of the entities summoned by Takahashi. All other wise beings have been consumed by an endless void, leaving only you and the magical grimoire of the former priestess, Abdur Irohzard, as the last hope. Time is running out, and every event is creeping up on your 0. Research has revealed that the spell uttered by Takahashi is an integer sequence of length N, represented as B1, B2, ..., BN. To restore peace to the world, you must utter a spell of length N, represented by the integer sequence A1, A2, ..., AN, that meets the following conditions:

  • Ai must be an integer between 1 and 10^6 (inclusive).
  • For each integer i where 1 ≤ i ≤ N, there exists a maximum integer 0 ≤ x < i such that the subsequence from A1 to Ax is equal to the subsequence from A−x+1Ai−x+1 to AiAi.

Determine whether there exists an integer sequence A1, A2, ..., AN that meets these conditions. If so, output 'Yes', and provide one example of such a sequence. If not, output 'No'.

Input Format

The input is provided from standard input in the following format:

N B1 B2 ... BN

Output Format

Output the following:

  • Line 1: 'Yes' if there exists a sequence that meets the conditions, otherwise 'No'.
  • Line 2: If a sequence exists, output one example separated by spaces.

Example Input #1

8 0 0 1 0 1 2 3 2

Example Output #1

Yes 1 2 1 3 1 2 1 2

Example Input #2

4 0 1 2 1

Example Output #2

No

Explanation of Examples

Example 1:

Consider i=6:

  • The subsequence from A1 to A2 is (1, 2), and the subsequence from A6+1−2A6+1−2 to A6A6 is (1, 2), which meets the condition. The same applies for i=2.
  • The subsequence from A1 to A4 is (1, 2, 1, 3), and the subsequence from A6+1−4A6+1−4 to A6A6 is (1, 3, 1, 2), which does not meet the condition. The maximum integer x that satisfies the condition is x=2, so A6=2B6=2 does not create any contradictions.

Constraints:

  • All inputs are integers.
  • 1 ≤ N ≤ 10^5
  • 0 ≤ Bi < i

原文地址: https://www.cveoy.top/t/topic/bKos 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录