CF - D. Colorful Stamp
找规律
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int main() {
int t;
cin >> t;
while (t --) {
int n;
cin >> n;
char s[n];
int r = 0, b = 0;
bool t = false;
for (int i = 0; i < n; i ++) {
cin >> s[i];
if(s[i] == 'R')r ++;
if(s[i] == 'B')b ++;
if (s[i] == 'W' &&(r != 0 || b != 0)){
if(r != 0 && b != 0) {
r = 0, b = 0;
}
else {
t = true;
}
}
}
if(r == 0 && b != 0)t = true;
if(r != 0 && b == 0)t = true;
if(t)cout <<"No"<<endl;
else cout << "Yes"<<endl;
}
return 0;
}