Result: Accepted
Time: 6ms
Memory: 1760kB
#include <bits/stdc++.h>
using namespace std;
char str[1100], brr[1100] ;
bool judge(char brr[], int len)
{
for(int i = 0 ; i < len / 2 ; ++ i)
{
if(brr[i] != brr[len- i - 1])
{
return 0 ;
}
}
return 1 ;
}
int main(int argc, char const *argv[])
{
int t ;
scanf("%d",&t) ;
getchar() ;
while(t --)
{
int flag = 0 ;
int flag1 = 0 ;
scanf("%s",str) ;
int len = strlen(str) ;
for(int i = 0 ; i < len / 2 ; ++ i)
{
if(str[i] != str[len- i - 1])
{
flag1 = 1 ;
}
}
if(flag1 == 0)
{
printf("Yes\n") ;
continue ;
}
for(int i = 0 ; i < len ; ++ i)
{
for(int j = 0, cnt = 0 ; j < len ; ++ j)
{
if(j == i) continue ;
brr[cnt ++ ] = str[j] ;
}
if(judge(brr,len-1))
{
printf("Yes\n") ;
flag = 1 ;
break ;
}
}
if(flag == 0)
printf("No\n") ;
}
return 0;
}