Mike and palindrome 水题

Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.

A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.

Input

The first and single line contains string s (1 ≤ |s| ≤ 15).

Output

Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.

Examples

Input

abccaa

Output

YES

Input

abbcca

Output

NO

Input

abcda

Output

YES

 

这题真的很水很水,但是还是错了,就是单纯想纪念一下错过的坑点,会犯一忘记了之后就会惯性的犯第二次 ,要尽最大可能避免这种情况的发生,毕竟水。

回文不管啥题了 时刻记得分奇偶就行。

 

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
string s;
int main(){
    cin >> s;
    bool ans=0;
    if(s.size()==1) ans = 1;
    if(s.size()&1){
        bool f=0;
        for(int j=0,k=s.size()-1; j<k; j++,k--){
                if(s[j]!=s[k]){
                    f=1;
                    break;
                }
        }
        if(!f) ans = 1;
    }
    for(int i=0; i<s.size(); i++){
        string t=s;
//        if(s.size()&1){
//            if(i==s.size()/2+1) continue;
//        }
        if(i<s.size()/2){
            if(t[i] != s[s.size()-i-1]){
                t[i] = s[s.size()-i-1];
            }
            else continue;
        }
        else {
            if(t[i] != s[s.size()-1-i]) t[i] = s[s.size()-1-i];
            else continue;

        }
//        cout << t<<endl;
        bool f=0;
        for(int j=0,k=t.size()-1; j<k; j++,k--){
            if(t[j]!=t[k]){
                f=1;
                break;
            }
        }
        if(!f) {
            ans = 1;
            break;
        }
    }
    if(ans) puts("YES");
    else puts("NO");
    return 0;
}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值