#C7158. Palindrome Substring Checker

    ID: 50998 Type: Default 1000ms 256MiB

Palindrome Substring Checker

Palindrome Substring Checker

Given a string \( s \) and \( q \) queries, each query consists of two integers \( l \) and \( r \) (1-indexed) representing the start and end positions in \( s \). For each query, determine whether the substring \( s[l \ldots r] \) is a palindrome. A palindrome is defined as a string that reads the same backward as forward. Your task is to output "YES" if the substring is a palindrome and "NO" otherwise.

Note: The substring boundaries are inclusive and the string indices are 1-indexed.

Example:

Input:
abacaba
3
1 3
2 4
1 7

Output: YES NO YES

</p>

Use the \( \LaTeX \) format for any formulas as shown above.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains the string \( s \).
  • The second line contains an integer \( q \) representing the number of queries.
  • Each of the following \( q \) lines contains two space-separated integers \( l \) and \( r \) (1-indexed) indicating the start and end indices of the substring.

outputFormat

For each query, output a single line to stdout containing "YES" if the specified substring \( s[l \ldots r] \) is a palindrome, and "NO" otherwise.

## sample
abacaba
3
1 3
2 4
1 7
YES

NO YES

</p>