CF1559B.Mocha and Red and Blue

普及/提高-

通过率:0%

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 nn 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 33 , 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.

输入格式

Each test contains multiple test cases.

The first line contains a single integer tt ( 1t1001 \le t \le 100 ) — the number of test cases. Each test case consists of two lines.

The first line of each test case contains an integer nn ( 1n1001\leq n\leq 100 ) — the length of the squares row.

The second line of each test case contains a string ss with length nn , containing characters 'B', 'R' and '?'. Here 'B' stands for a blue square, 'R' for a red square, and '?' for a blank square.

输出格式

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.

输入输出样例

  • 输入#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 11 (since squares 22 and 33 have the same color), which is the minimum possible imperfectness.

首页