QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#4217. グラフ彩色

統計

$n \le 3000$ 個の頂点を持つトーナメントグラフ(任意の異なる2頂点 $i, j$ について、$i \to j$ または $j \to i$ のいずれか一方のみが存在する完全有向グラフ)が与えられます。このグラフの各辺を14色で塗り分ける必要があります。

グラフ内の任意のパス $i \to j \to k$ において、辺 $i \to j$ の色と辺 $j \to k$ の色が同じにならないようにしてください。

これが常に可能であることが保証されています。

入力

入力の最初の行には、トーナメントグラフの頂点数を表す整数 $n$ ($3 \le n \le 3000$) が与えられます。

続く $n - 1$ 行にはグラフの記述が含まれます。$i$ 行目には $i$ 文字のバイナリ文字列が与えられます。

この文字列の $j$ 番目の文字が '1' である場合、グラフには $(i + 1) \to j$ という辺が存在します。そうでない場合、$j \to (i + 1)$ という辺が存在します。

出力

出力は $n - 1$ 行からなり、$i$ 行目には $i$ 文字の文字列を含める必要があります。

この文字列の $j$ 番目の文字は 'a' から 'n' までの小文字のラテン文字である必要があります。グラフに $(i + 1) \to j$ という辺が存在する場合、この文字はその辺 $(i + 1) \to j$ の色を表します。そうでない場合、その辺 $j \to (i + 1)$ の色を表します。

入出力例

入力 1

3
1
11

出力 1

a
ab

入力 2

5
1
10
100
0100

出力 2

a
bc
def
ghij

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.