这个题简单,只要暴力的去判断是否是由连续的mq组成的,那么如果长度为奇数一定不可以,那么对于偶数长度,我们两个两个看,如果出现两个不是mq的就输出No,否则输出Yes
code
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int main()
{ char s[N];
int t;
scanf("%d",&t);
while(t--)
{
scanf("%s",s);
if(strlen(s)%2) {
cout<<"No"<<endl;
continue;
}
int ok=1;
for(int i=0;i<strlen(s);i+=2)
{
if(s[i]=='m'&&s[i+1]=='q') ;
else ok=0;
}
if(ok) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}


京公网安备 11010502036488号