AtCoder ABC346 A-E题解-Problem B:

时间:2024-03-25 09:20:08

这题并不需要什么高级的玩意,只用把S复制几遍,然后暴力判断即可。(思路源于tourist的代码)

#include <bits/stdc++.h>
using namespace std;
int main(){
	string S="wbwbwwbwbwbw";
	while(S.size()<10000)
		S+=S;
	int W,B;
	cin>>W>>B;
	for(int i=0;i<((int)S.size()-W-B);i++){
		string t=S.substr(i,W+B);
		if(count(t.begin(),t.end(),'w')==W){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	//cout<<"No"<<endl;
	return 0;
}