10pts,求dalao悬关
查看原帖
10pts,求dalao悬关
1047537
wuzhuoran楼主2024/8/24 21:18
#include<bits/stdc++.h>
using namespace std;

int t;
string s;

int main(){
	cin>>t;
	while(t--){
		cin>>s;
		string str1,str2;
		bool f=false,l=false;
		if(s[0]!='l'&&s[0]!='q'&&s[0]!='b'){		
			for(int i=0; i<s.size(); i++){
			    if(s[i]!='l'&&s[i]!='q'&&s[i]!='b'){
				    if(f==true){
				    	cout<<"No"<<endl;
				    	l=true;
				    	break;
					}		
					else{
						str1+=s[i];
					}
		        }
				else{
					f=true;
				}		
			}
		}
		else{
			for(int i=0; i<s.size(); i++){
			    if(s[i]!='l'&&s[i]!='q'&&s[i]!='b'){
				   	cout<<"No"<<endl;
				   	l=true;
				   	break;
		        }	
			}			
		}
		str2=str1;
		std::reverse(str1.begin(), str1.end());
		if(str2!=str1){
			cout<<"No"<<endl;
			l=true;
		}
		if(l==false){
			cout<<"Yes"<<endl;
		}
    }
    return 0;
}

2024/8/24 21:18
加载中...