QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#4217. 圖著色

统计

你被給予一個錦標賽圖(tournament),這是一個完全有向圖(對於任意兩個不同的頂點 $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)$ 的顏色。

範例

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