#abc237c. C - kasaka

C - kasaka

Score : 300300 points

问题描述

已知一个由小写英文字母组成的字符串 SS。判断在 SS 开头添加任意数量(可能为零)的 a 是否能使它成为一个回文串。

这里,长度为 NN 的字符串 A=A1A2ANA=A_1A_2\ldots A_N 被称为回文串,当且仅当对于所有满足 1iN1\leq i\leq Nii,有 Ai=AN+1iA_i=A_{N+1-i}

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given is a string SS consisting of lowercase English letters. Determine whether adding some number of a's (possibly zero) at the beginning of SS can make it a palindrome.

Here, a string of length NN, A=A1A2ANA=A_1A_2\ldots A_N, is said to be a palindrome when Ai=AN+1iA_i=A_{N+1-i} for every 1iN1\leq i\leq N.

Constraints

  • 1S1061 \leq \lvert S \rvert \leq 10^6
  • SS consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

SS

Output

If adding some number of a's (possibly zero) at the beginning of SS can make it a palindrome, print Yes; otherwise, print No.

Sample Input 1

kasaka

Sample Output 1

Yes

By adding one a at the beginning of kasaka, we have akasaka, which is a palindrome, so Yes should be printed.

Sample Input 2

atcoder

Sample Output 2

No

Adding any number of a's at the beginning of atcoder does not make it a palindrome.

Sample Input 3

php

Sample Output 3

Yes

php itself is a palindrome. Adding zero a's at the beginning of SS is allowed, so Yes should be printed.

update @ 2024/3/10 10:15:20