为什么会re,请帮助
查看原帖
为什么会re,请帮助
441439
rbjqrjy0001楼主2025/1/21 11:56
#include<bits/stdc++.h>
using namespace std;
bool hw( string x  ){
	bool f = 1 ; 
	for( int  i = 0  ; i <= (x.size()-1) /2 ; i++ ){
		if( x[i] != x[x.size()-1-i] ){
			f = 0 ;
			break;
		}
	} 
	return f ; 
}
int main(){
	// 读入一个字符串  枚举出所有可能分段方式 
	// 判断子串1 和子串2 是不是同为回文  
	int  n ; 
	cin >> n ; 
	string s ; 
	while( n-- ){
		cin >> s ; 
		// 枚举出所有可能分段方式
		bool bj = 1 ; 
		for( int i = 2 ; i <= s.size()-2 ; i++  ){
			// i 前串的长度  s.size() -i  后串的长度
			string q = s.substr(0, i ) ; 
			string h = s.substr(i) ; 
			if( hw(q) == 1 && hw(h) == 1 ){
				cout<< "Yes"<< endl ; 
				bj = 0 ; 
				break;
			} 
		} 
		if( bj == 1 ){
			cout<< "No"<< endl; 
		}
	} 
	
	return 0 ;
}


2025/1/21 11:56
加载中...