100分求调
查看原帖
100分求调
1080304
Mario_iostream楼主2025/1/19 20:03
#include <iostream>
#include <string>
bool isPalindrome(const std::string& s) {
	int left = 0, right = s.length() - 1;
	while (left < right) {
		if (s[left] != s[right])return false;
		left++;
		right--;
	}
	return true;
}
bool isConcatenatedPalindrome(const std::string& s) {
	int n = s.length();
	for (int i = 2; i <= n - 2; i++) {
		if (isPalindrome(s.substr(0, i)) && isPalindrome(s.substr(i)))return true;
	}
	return false;
}

int main() {
	int n;
	std::cin >> n;
	std::cin.ignore();
	for (int i = 0; i < n; i++) {
		std::string s;
		std::getline(std::cin, s);
		if (isConcatenatedPalindrome(s))std::cout << "Yes" << std::endl;
		else std::cout << "No" << std::endl;
	}
	return 0;
}
2025/1/19 20:03
加载中...