問題一覧 > 通常問題

No.1370 Substitution Kadomatsu Sequence

レベル : / AI推定難易度 : 1325 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 79
作問者 : mai / テスター : QCFium
お気に入りにしたユーザー ProblemId : 3118 / 自分の提出
問題文最終更新日: 2020-11-05 23:39:32
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 280 (門松コンテスト) (順位表) の他の問題:

Definition

It has been handed down that a sequence $v = (a_1,a_2,a_3)$ consisting of 3 elements is a Kadomatsu sequence if $v$ satisfies the following conditions.

  1. $a_1,a_2,a_3$ are all distinct
  2. Among the 3 elements, $a_2$ is the largest or the smallest

Furthermore, when a sequence $w = (a_1,...,a_n)$ consisting of $n$ elements (where $3\le n$) is such that
any 3 consecutive elements taken from it form a Kadomatsu sequence, $w$ is called a Kadomatsu sequence sequence.

Problem Statement

Determine whether there exists an assignment of $x_1, x_2, \ldots, x_M$ such that the sequence $x_{a_1}, x_{a_2}, \ldots, x_{a_N}$ is a Kadomatsu sequence sequence, and if one exists, output one such assignment.

Input

$N$ $M$
$a_1$ .. $a_N$

$3 \le N \le 10^5$
$1 \le M \le 10^5$
$1 \le a_i \le M$
All values in the input are integers.

Output

If no assignment satisfying the condition exists, output No.

If one exists, output Yes, and then output $x_1, x_2, \ldots, x_M$ separated by newlines or by single-byte spaces.
They must be integers satisfying the constraint $1 \le x_i \le 10^9$.

This problem uses a special judge. There are multiple solutions, and you may output any of them.

Sample

Sample 1
Input
4 3
1 2 3 1
Output
Yes
2 3 1

Assigning as in the output gives 2 3 1 2. This is a Kadomatsu sequence sequence.

Outputting 4 3 5 is also OK.

Sample 2
Input
5 3
1 3 3 3 1
Output
No

There may be unused variables.

Sample 3
Input
6 3
1 2 3 1 2 3
Output
No

Sample 4
Input
9 9
9 8 7 6 5 4 3 2 1
Output
Yes
1 3 2 4 1 3 2 5 4

The sample output is merely one example. There are multiple solutions.

Sample 5
Input
3 2
2 1 2
Output
No

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。