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;
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 12:18
点赞 评论 收藏
分享
难怪不开摄像头,全是简单的性格题,比大疆友善多了
NULL10086:今早上发的测评,我这还没做呢,官网上已经显示挂了
投递大疆等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务