QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 10

#11182. 环形游戏 [A]

Statistics

在“环形游戏”中,棋盘由 $m$ 个格子组成,排成一个圆圈,编号从 1 到 $m$。在棋盘上有 $b$ 个白色棋子和 $c$ 个黑色棋子,每个格子上最多只有一个棋子。游戏由两名玩家进行,分别是白方和黑方。从白方开始,双方轮流在棋盘上行动。每一步行动是将自己颜色的某个棋子向前或向后移动任意数量的空格。例如,对于下图所示的棋盘,白方可以将第 3 格的棋子移动到第 4 格,或者将第 8 格的棋子移动到第 7、9 或 1 格。

problem_11182_1.gif

如果某名玩家在其回合中无法进行任何移动,则该玩家输掉比赛。已知双方都以最优策略进行游戏,判断谁将获胜。也有可能出现没有一方获胜(即游戏永远不会结束)的情况。

输入格式

标准输入的第一行包含一个整数 $t$,表示要处理的棋盘数量。接下来的内容是每个棋盘的描述,每个棋盘由三行组成。第一行包含三个整数 $m$、$b$ 和 $c$($1 ≤ m ≤ 10^{9}$,$1 ≤ b, c$),用空格分隔,分别表示棋盘的长度、白棋的数量和黑棋的数量。第二行为一个递增的 $b$ 个整数序列(范围为 $1, \ldots, m$),表示白棋的位置。第三行为一个递增的 $c$ 个整数序列(范围为 $1, \ldots, m$),表示黑棋的位置。所有棋盘中的总棋子数不超过 $10^{6}$。

输出格式

标准输出应包含恰好 $t$ 行,每行对应一个棋盘的答案。答案是一个单字符:BCR,分别表示白方获胜(B)、黑方获胜(C)或游戏永不结束(R)。

样例

输入

3
9 2 3
3 8
2 5 6
6 2 2
5 6
2 4
7 1 1
3
4

输出

C
B
R
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.