#K47012. Contains Palindrome Query
Contains Palindrome Query
Contains Palindrome Query
You are given a string S and a number of queries. For each query, determine whether there exists a substring of S of a specified length that is a palindrome. A string (or substring) is a palindrome if it reads the same backwards as forwards. Formally, for a substring P of S with length \(Q\), P is a palindrome if \(P = \text{reverse}(P)\). For each query, output Yes
if such a substring exists and No
otherwise.
inputFormat
The input is given in the following format:
- The first line contains the string S.
- The second line contains an integer N representing the number of queries.
- The third line contains N space-separated integers. Each integer represents a query for the length of the substring to check.
outputFormat
For each query, output Yes
if there is at least one substring of length Q that is a palindrome, and No
otherwise. Each answer should be printed on a separate line.
abacaba
1
3
Yes
</p>