CF1559B.Mocha and Red and Blue
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
As their story unravels, a timeless tale is told once again...
Shirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha interesting puzzles to solve. This day, Shirahime comes up with a new simple puzzle and wants Mocha to solve them. However, these puzzles are too easy for Mocha to solve, so she wants you to solve them and tell her the answers. The puzzles are described as follow.
There are n squares arranged in a row, and each of them can be painted either red or blue.
Among these squares, some of them have been painted already, and the others are blank. You can decide which color to paint on each blank square.
Some pairs of adjacent squares may have the same color, which is imperfect. We define the imperfectness as the number of pairs of adjacent squares that share the same color.
For example, the imperfectness of "BRRRBBR" is 3, with "BB" occurred once and "RR" occurred twice.
Your goal is to minimize the imperfectness and print out the colors of the squares after painting.
随着故事徐徐展开,一个永恒的传说再次被娓娓道来……
Shirahime 是 Mocha 的一位朋友,热衷于玩音乐游戏 Arcaea,并且喜欢给 Mocha 出一些有趣的谜题来解答。这一天,Shirahime 想出了一个全新的简单谜题,希望 Mocha 能够解答。然而,这些谜题对 Mocha 来说太过简单,因此她希望你来解答它们,并将答案告诉她。谜题描述如下:
有 n 个正方形排成一行,每个正方形可以涂成红色或蓝色。
这些正方形中,一部分已经被涂色,其余则为空白。你可以自行决定每个空白正方形应涂成何种颜色。
某些相邻正方形可能具有相同颜色,这被视为不完美。我们将“不完美度”定义为具有相同颜色的相邻正方形对的数量。
例如,“BRRRBBR”的不完美度为 3,其中“BB”出现一次,“RR”出现两次。
你的目标是使不完美度最小化,并输出涂色完成后的各正方形颜色。
输入格式
Each test contains multiple test cases.
The first line contains a single integer t (1≤t≤100) — the number of test cases. Each test case consists of two lines.
The first line of each test case contains an integer n (1≤n≤100) — the length of the squares row.
The second line of each test case contains a string s with length n, containing characters 'B', 'R' and '?'. Here 'B' stands for a blue square, 'R' for a red square, and '?' for a blank square.
每个测试包含多个测试用例。
第一行包含一个整数 t(1≤t≤100)—— 测试用例的数量。每个测试用例由两行组成。
每个测试用例的第一行包含一个整数 n(1≤n≤100)—— 方格行的长度。
每个测试用例的第二行包含一个长度为 n 的字符串 s,其中仅包含字符 'B'、'R' 和 '?'。其中,'B' 表示蓝色方格,'R' 表示红色方格,'?' 表示空白方格。
输出格式
For each test case, print a line with a string only containing 'B' and 'R', the colors of the squares after painting, which imperfectness is minimized. If there are multiple solutions, print any of them.
对于每个测试用例,输出一行仅包含字符 'B' 和 'R' 的字符串,表示涂色后各方格的颜色,使得“不完美度”最小。若存在多个解,输出任意一个即可。
输入输出样例
输入#1
5 7 ?R???BR 7 ???R??? 1 ? 1 B 10 ?R??RB??B?
输出#1
BRRBRBR BRBRBRB B B BRRBRBBRBR
说明/提示
In the first test case, if the squares are painted "BRRBRBR", the imperfectness is 1 (since squares 2 and 3 have the same color), which is the minimum possible imperfectness.
在第一个测试用例中,如果方格被涂成“BRRBRBR”,则不完美度为 1(因为第 2 个和第 3 个方格颜色相同),这是可能的最小不完美度。
输入解题思路,AI测评打分。不知道怎么写?