Here is my code for task B String Palindrome (B - String Palindrome):-
#include <bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007
bool isPalin(string s, int i, int j)
{
for(int x=i, y=j; x != y; x++, y--)
{
if(s[x] != s[y]) return false;
}
return true;
}
int main()
{
FastIO
string s;
cin >> s;
int n = s.size();
if(isPalin(s,0,n-1))
{
if(isPalin(s,0,(n-1)/2 - 1))
{
if(isPalin(s,(n+3)/2 - 1, n-1))
{
cout << "Yes\n";
}
else cout << "No\n";
}
else cout << "No\n";
}
else cout << "No\n";
return 0;
}
It gives AC on 4 test cases. What is wrong in this code? Can anyone please help?