// C++ program to find palindromic substrings of a string #include #include using namespace std; // Returna total number of palindrome substring of // length greater then equal to 2 int CountPS(string str, int n) { int dp[n][n]; memset(dp, 0, sizeof(dp)); // P[i][j] = true if substring str[i..j] is palindrome, // else false bool P[n][n]; memset(P, false , sizeof(P)); // palindrome of single lenght for (int i= 0; i< n; i++) P[i][i] = true; // palindrome of length 2 for (int i=0; i>s; int l,r,t; cin>>t; while(t-->0) { cin>>l>>r; s1=s.substr(l,r); cout << (CountPS(s1, r-l)+1) << endl; } return 0; }