欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1559B.Mocha and Red and Blue
Mocha and Red and Blue
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 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 , 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.
Input
Each test contains multiple test cases.
The first line contains a single integer () — the number of test cases. Each test case consists of two lines.
The first line of each test case contains an integer () — the length of the squares row.
The second line of each test case contains a string with length , containing characters 'B', 'R' and '?'. Here 'B' stands for a blue square, 'R' for a red square, and '?' for a blank square.
Output
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.
Note
In the first test case, if the squares are painted "BRRBRBR", the imperfectness is (since squares and have the same color), which is the minimum possible imperfectness.
Samples
5
7
?R???BR
7
???R???
1
?
1
B
10
?R??RB??B?
BRRBRBR
BRBRBRB
B
B
BRRBRBBRBR
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |