QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 512 MB 満点: 100

#3678. LED-led 路径

統計

在一个大城市中有 $n$ 个路口和 $m$ 条连接这些路口的单向街道。已知城市中不存在有向环,因此人们无法在街道上无限行走。

旅游部门决定使用 LED(发光二极管)技术安装彩色照明。每条街道都要被照明为红色 (R)、绿色 (G) 或蓝色 (B) 中的一种颜色。

官方的城市旅游地图将标明所选的颜色。所有由相同颜色照明的连续路径都将被推荐用于步行和观光。由于 LED 会引导人们沿着美丽的路线行走,这些路径被称为“LED 引导路径”(LED-led paths)。

卫生部门表示,如果存在非常长的单色 LED 引导路径,一些游客可能会高估自己的体力,走得太久,导致过度疲劳,从而对城市产生反感。

请提出一种三色照明方案,使得没有任何单色 LED 引导路径包含超过 42 条街道。

插图

输入格式

第一行包含两个整数 $n$ 和 $m$,分别表示路口数量和街道数量 ($2 \le n \le 50\,000$; $1 \le m \le 200\,000$)。

接下来的 $m$ 行,每行包含两个整数 $u_i$ 和 $v_i$,表示一条从路口 $u_i$ 到路口 $v_i$ 的单向街道 ($1 \le u_i, v_i \le n$; $u_i \neq v_i$)。

保证给定的城市是无环的。每对路口之间最多只有一条街道相连。

输出格式

对于每条街道,按照输入顺序,在单独的一行中输出其颜色——即单个字母 R、G 或 B。

样例

输入格式 1

5 6
5 3
3 1
1 2
2 4
5 2
3 4

输出格式 1

B
R
G
R
B
G

说明

在此样例中,所有单色 LED 引导路径的长度都不超过一条街道(因此也不超过 42 条街道),这完全符合卫生部门的要求。

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.