QOJ.ac

QOJ

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

#4217. 图着色

統計

给定一个锦标赛图,它是一个完全有向图(对于任意两个不同的顶点 $i, j$,在 $i \to j$ 和 $j \to i$ 之间恰好存在一条边),且顶点数 $n \le 3000$。你需要将其边染成 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)$ 的颜色。

图中不应存在路径 $i \to j \to k$,使得边 $i \to j$ 和 $j \to k$ 的颜色相同。

样例

输入格式 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.