CF2209D.Ghostfires
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
OtterZ decided to make a weapon using ghostfires. He collected several ghostfires in colors red, green, and blue. He will put some of the ghostfires in a row to build the weapon. To make the weapon more powerful, OtterZ will use as many ghostfires as possible, but the weapon will be out of control if there are two ghostfires of the same color adjacent or separated by exactly two ghostfires in the row.
Formally, OtterZ collected r red ghostfires, g green ghostfires, and b blue ghostfires. He wants to construct a string s consisting of the characters 'R', 'G', and 'B' that satisfies the following conditions:
- The number of occurrences of 'R', 'G', and 'B' in s does not exceed r, g, and b, respectively.
- For all 1≤i≤∣s∣−1, si=si+1.
- For all 1≤i≤∣s∣−3, si=si+3.
- The length of s is the maximum possible.
Help OtterZ to construct the row. Although there may be several possible rows, OtterZ just requires one of them.
OtterZ 决定使用幽灵火焰来制造一件武器。他收集了若干红色、绿色和蓝色的幽灵火焰。他将把其中一部分幽灵火焰排成一行来构建该武器。为了使武器更强大,OtterZ 希望尽可能多地使用幽灵火焰;但若在该行中存在两个同色的幽灵火焰,且它们相邻或中间恰好间隔两个幽灵火焰(即位置相差为 3),则武器将失控。
形式化地,OtterZ 收集了 r 个红色幽灵火焰、g 个绿色幽灵火焰和 b 个蓝色幽灵火焰。他希望构造一个由字符 'R'、'G' 和 'B' 组成的字符串 s,满足以下条件:
- 字符串 s 中
'R'、'G'和'B'的出现次数分别不超过 r、g 和 b; - 对所有 1≤i≤∣s∣−1,有 si=si+1;
- 对所有 1≤i≤∣s∣−3,有 si=si+3;
- 字符串 s 的长度尽可能大。
请帮助 OtterZ 构造这样的一行。尽管可能存在多个满足条件的字符串,OtterZ 只需要其中任意一个即可。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The only line of each test case contains three integers r, g, and b (0≤r,g,b≤106, r+g+b>0), representing the number of red, green, and blue ghostfires, respectively.
It is guaranteed that the sum of r+g+b over all test cases does not exceed 106.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例仅有一行,包含三个整数 r、g 和 b(0≤r,g,b≤106,且 r+g+b>0),分别表示红色、绿色和蓝色幽灵火的数量。
保证所有测试用例中 r+g+b 的总和不超过 106。
输出格式
For each query, output a string s consisting of the characters 'R', 'G', and 'B', where si equals 'R', 'G' or 'B' indicates that the i-th ghostfire is colored red, green, or blue, respectively.
If there are multiple answers, output any.
对于每个查询,输出一个由字符 'R'、'G' 和 'B' 组成的字符串 s,其中 si 为 'R'、'G' 或 'B' 分别表示第 i 个幽灵火被染成红色、绿色或蓝色。
如果存在多个合法答案,输出任意一个即可。
输入输出样例
输入#1
5 0 0 1 1 1 1 0 3 0 2 2 2 2 7 3
输出#1
B RGB G GBRBRG GRGRGBGBGBG
说明/提示
For the first test case, "B" is the only valid construction.
For the second test case, "RGB", "RBG", "GRB", "GRB", "BRG", and "BGR" are all correct.
For the third test case, "GG" and "GGG" are invalid because s1=s2.
对于第一个测试用例,“B”是唯一有效的构造。
对于第二个测试用例,“RGB”、“RBG”、“GRB”、“GRB”、“BRG”和“BGR”均为正确答案。
对于第三个测试用例,“GG”和“GGG”均无效,因为 s1=s2。
输入解题思路,AI测评打分。不知道怎么写?