/*B. Mocha and Red and Blue
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output*/
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/374212248036113.jpg "=600 #left")
codeforces原题网址https://codeforces.com/problemset/problem/1559/B
自己带了各种数据都对的
但是 带入测试点这个数据:
1
5
RR???
在我电脑上算的是RRBRB,正确
在codeforces里算是BRBRB,错误
这个测试数据导致我不过
为什么同一个代码算出来结果不一样?找不到解决办法?求解决后提交获得AC的代码,谢谢。
```c++
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main()
{
int i1 = 0, i2 = 0;
int num;
cin >> num;
string* s = new string[num];
for (int j = 0; j < num; ++j)
{
int N;
cin >> N;
cin >> s[j];
for (int i = 0; i < N - 1; ++i)
{
if (s[j][i] != '?' && s[j][i + 1] == '?')
{
for (i2 = i + 1; s[j][i2] == '?'; ++i2);
for (int t1 = i + 1; t1 < i2; ++t1)
s[j][t1] = (s[j][t1 - 1] == 'B' ? 'R' : 'B');
i = i2 - 1;
}
}
if (s[j][0] == '?')
for (i1 = 0; s[j][i1] == '?'; ++i1);
for (int t1 = i1 - 1; t1 >= 0; --t1)
s[j][t1] = (s[j][t1 + 1] == 'B' ? 'R' : 'B');
if (s[j][N - 1] == '?')
for (i2 = N - 1; s[j][i2] == '?'; --i2);
for (int t2 = i2 + 1; t2 <= N - 1; ++t2)
s[j][t2] = (s[j][t2 - 1] == 'B' ? 'R' : 'B');
}
for (int i = 0; i < num; ++i)
{
cout << s[i] << endl;
}
return 0;
}
```