QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#895. 色

Statistics

Big Horse は数学の神である。彼は $n$ 個の頂点を持つ完全無向グラフを描いた。各辺は $1, \dots, m$ のいずれかの色で塗られている。Big Horse は、このグラフを可能な限り最大の完全グラフに拡張するという大きな野望を抱いている。その条件は、同じ端点を共有する任意の2つの辺が異なる色を持つことである。彼は、このグラフが最大でも $m + 1$ 個の頂点しか持てないことに気づいた。そこで彼は、自身のグラフを $m + 1$ 個の頂点を持つグラフに拡張できるかどうかをあなたに尋ねている。

入力

1行目に2つの整数 $n$ と $m$ ($1 \le n \le 200, 1 \le m \le 200, n \le m + 1$) が与えられる。

続く $n - 1$ 行には、グラフの情報が与えられる。$i$ 番目の行には $n - i$ 個の数字が並んでいる。その行の $j$ 番目の数字は、頂点 $i$ と頂点 $i + j$ を結ぶ辺の色を表す。すべての色は $1$ から $m$ までの整数である。

出力

グラフを拡張できる場合は1行目に "Yes" と出力し、そうでない場合は "No" と出力せよ。

1行目が "Yes" の場合、続けて $m$ 行を出力せよ。$i$ 番目の行には $m + 1 - i$ 個の数字を出力せよ。その行の $j$ 番目の数字は、頂点 $i$ と頂点 $i + j$ を結ぶ辺の色を表す。入力で与えられた辺は、入力と同じ色でなければならない。同じ端点を共有する任意の2つの辺は、異なる色でなければならない。複数の解が存在する場合は、そのうちのいずれかを出力せよ。

入出力例

入力 1

3 5
1 2
4

出力 1

Yes
1 2 4 3 5
4 3 5 2
5 1 3
2 1
4

入力 2

4 5
1 2 3
3 2
1

出力 2

No

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.