#P10905. [蓝桥杯 2024 省 C] 回文字符串

[蓝桥杯 2024 省 C] 回文字符串

Problem Description

Xiao Lan has recently become interested in palindrome strings. He has a string SS that contains only lowercase letters. Xiao Lan may add any number of the specified characters l, q, b (their ASCII codes are 108108, 113113, and 9898, respectively) to the beginning of the string SS. Xiao Lan wants to know whether he can turn the string SS into a palindrome string in this way.

Input Format

The first line of the input contains an integer TT, meaning that each input contains TT test cases.

Next, TT test cases are described in order.

Each test case consists of one line containing a string SS.

Output Format

Output TT lines. Each line contains a string representing the answer for the corresponding test case. If SS can be turned into a palindrome string, output Yes; otherwise, output No.

3
gmgqlq
pdlbll
aaa
Yes
No
Yes

Hint

[Sample Explanation]

For gmgqlq, you can add qlq in front => qlqgmgqlq to turn it into a palindrome string.

For pdlbll, it cannot be turned into a palindrome string.

For aaa, it is already a palindrome string.

[Constraints]

For 50%50\% of the test cases, 1S10001 \le |S| \le 1000, where S|S| denotes the length of the string SS.
For all test cases, 1T101 \le T \le 10, 1S1061 \le \sum |S| \le 10^6.

Translated by ChatGPT 5