Educational Codeforces Round 73 (Rated for Div. 2)E(思维,博弈)

#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int length[300007];
int main(){
ios::sync_with_stdio(false);//多组数据输入cin,cout容易超时
cin.tie(NULL);
cout.tie(NULL);
int q;
cin>>q;
while(q--){
int a,b;
cin>>a>>b;
string s;
cin>>s;
int n=s.size();
int tmp=0;
int cnt1=0,cnt2=0,cnt3=0;
int len=0;
for(int i=0;i<n;++i){
if(s[i]=='.')
++tmp;
else{
if(tmp>=b&&tmp<a)
++cnt1;
else if(tmp>=a&&tmp<2*b)
++cnt2;
else if(tmp>=2*b)
++cnt3,len=tmp;
tmp=0;
}
}
if(s[n-1]=='.'){
if(tmp>=b&&tmp<a)
++cnt1;
else if(tmp>=a&&tmp<2*b)
++cnt2;
else if(tmp>=2*b)
++cnt3,len=tmp;
}
if(cnt3>=2||cnt1)
cout<<"NO\n";
else if(!cnt3){
if(cnt2&1)
cout<<"YES\n";
else
cout<<"NO\n";
}
else if(cnt2&1){
if(len>=2*a&&len<a+3*b-1)
cout<<"YES\n";
else
cout<<"NO\n";
}
else{
if(len<=a+2*b-2||len>=3*a&&len<a+4*b-1)
cout<<"YES\n";
else
cout<<"NO\n";
}
}
return 0;
}

猜你喜欢

转载自www.cnblogs.com/ldudxy/p/11568895.html