Universal Cup Judging System

Universal Cup

Time Limit: 3.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓
Statistics

明年,“过度复杂问题研讨会”(Overly Complicated Problem Colloquium)将在“宏伟壮丽城”(Greatly Magnificent City)举行。为了给客人们留下深刻印象,目前正在进行几项建设工程,其中包括粉刷城市中所有的街道。

正如预期的那样,这座城市由 $n$ 个路口和 $m$ 条连接它们的双向街道组成。路口编号为 $1 \dots n$。任意两个路口之间最多只有一条街道直接相连,没有街道连接路口自身,且通过这些街道可以从任意路口到达其他任何路口。

每条街道都需要被粉刷成红色或蓝色。市长认为,如果每条街道的颜色都与上一条不同,那么在城市中漫步会更有趣。因此,市长提出了一个额外的限制条件:“如果 $p$ 和 $q$ 是不同的路口,那么必须存在一条从 $p$ 到 $q$ 的路径,使得路径上每一条街道的颜色都与前一条街道的颜色不同。”这样的路径可以多次经过某些街道或路口。

你的任务是建议一种粉刷所有街道的方法,以满足市长的要求,或者指出这是不可能的。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 1000$),表示测试用例的数量。接下来是 $t$ 个测试用例。每个测试用例的描述如下:

第一行包含两个整数 $n$ 和 $m$ —— 分别表示路口数量和街道数量 ($2 \le n \le 100, 1 \le m \le 300$)。接下来的 $m$ 行,每行包含两个整数 $u$ 和 $v$ ($1 \le u \le n, 1 \le v \le n$),表示连接路口 $u$ 和 $v$ 的一条街道。

保证在每个输入文件中,满足 $n > 50$ 或 $m > 150$ 的测试用例不超过 100 个。

输出格式

对于每个测试用例,请在单独的一行中打印答案:

  • 如果无法满足市长的要求,打印 IMPOSSIBLE
  • 否则,打印一个长度为 $m$ 的字符串。字符串的第 $i$ 个字符应为 B(如果第 $i$ 条路是蓝色),否则为 R

样例

输入 1

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

输出 1

RRRBBB
RBBRBB
IMPOSSIBLE

说明

样例中的额外换行符仅为了方便阅读,实际输入中并不存在。

下图展示了前两个测试用例的一种可行染色方案。

在第三个测试用例中,无论你如何粉刷边,总会存在一对叶子节点,且通向它们的边颜色相同,这使得该条件无法满足。

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.