#C12047. Palindromic Substring Queries
Palindromic Substring Queries
Palindromic Substring Queries
You are given a string s of length \( l \) and \( q \) queries. Each query consists of two integers \( a \) and \( b \) (1-indexed) representing the starting and ending positions in the string. Your task is to determine for each query whether the substring \( s[a \ldots b] \) is a palindrome.
A palindrome is a sequence that reads the same backward as forward. For each query, output "Yes" if the substring is a palindrome, and "No" otherwise.
Note: All indices are 1-based. That is, the first character of the string is at index 1.
Constraints:
- \( 1 \leq l \leq 10^5 \)
- \( 1 \leq q \leq 2\times10^4 \)
- \( 1 \leq a \leq b \leq l \)
Example:
Input: abacaba 3 1 3 2 4 1 7</p>Output: Yes No Yes
inputFormat
The first line contains the string s (without spaces). The second line contains an integer q representing the number of queries. The next q lines each contain two integers a and b separated by a space, meaning that you need to consider the substring from index a to b (inclusive) of the string s.
outputFormat
For each query, output one line containing either "Yes" if the specified substring is a palindrome or "No" otherwise.
## samplea
1
1 1
Yes
</p>