102372: [AtCoder]ABC237 C - kasaka

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

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

Here, a string of length $N$, $A=A_1A_2\ldots A_N$, is said to be a palindrome when $A_i=A_{N+1-i}$ for every $1\leq i\leq N$.

Constraints

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

Input

Input is given from Standard Input in the following format:

$S$

Output

If adding some number of a's (possibly zero) at the beginning of $S$ 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 $S$ is allowed, so Yes should be printed.

Input

题意翻译

给出字母组成的字符串 $S$,问能否通过在 $S$ 的前面添加若干个 `a`(可以为 $0$ 个),使得 $S$ 为回文串。 $\text{translated by @fengguangxi}$

Output

分数:300分

问题描述

给定一个由小写英文字母组成的字符串$S$。 确定在$S$的开头添加任意数量的a(包括零个)是否可以使它成为一个回文字符串。

这里,长度为$N$的字符串$A=A_1A_2\ldots A_N$,当对于所有$1\leq i\leq N$时有$A_i=A_{N+1-i}$时,称为回文字符串。

限制条件

  • $1 \leq \lvert S \rvert \leq 10^6$
  • $S$由小写英文字母组成。

输入

输入从标准输入按照以下格式给出:

$S$

输出

如果在$S$的开头添加任意数量的a(包括零个)可以使它成为一个回文字符串,则打印Yes;否则,打印No


样例输入1

kasaka

样例输出1

Yes

kasaka的开头添加一个a,得到akasaka,这是一个回文字符串,因此应打印Yes


样例输入2

atcoder

样例输出2

No

atcoder的开头添加任意数量的a,并不能使其成为回文字符串。


样例输入3

php

样例输出3

Yes

php本身就是一个回文字符串。在$S$的开头添加零个a是允许的,因此应打印Yes

加入题单

算法标签: