1 solutions

  • 0
    @ 2026-11-14 11:36:55

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    bool check(string s){
    	if (s.size()<2) return false;
    	for (int i = 0;i<s.size()/2;i++){
    		if (s[i] != s[s.size()-i -1 ] ) 
    			return false;
    	}
    	return true;
    }
    
    void solve(){
    	string s;
    	cin >> s;
    	for (int i = 2;i<s.size()-1;i++){
    		string l = s.substr(0,i);
    		string r = s.substr(i);
    		if (check(l) && check(r)) {
    			cout << "Yes" << endl;
    			return;	
    		}
    	}
    	cout << "No" << endl;
    }
    
    int main(){
    	int n;
    	cin >> n;
    	while(n--){
    		solve();
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    149
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By