#abc307b. B - racecar
B - racecar
Score : points
问题描述
你已知 个由小写英文字母组成的字符串 。
判断是否存在 不同的 整数 和 ,满足 (包含两端点),使得按顺序拼接的 和 构成一个回文串。
若长度为 的字符串 满足对于所有 ,其第 个字符与第 个字符相同,则称该字符串 是回文串。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given strings consisting of lowercase English letters.
Determine if there are distinct integers and between and , inclusive, such that the concatenation of and in this order is a palindrome.
A string of length is a palindrome if and only if the -th character and the -th character of are the same for every .
Constraints
- is an integer.
- is a string consisting of lowercase English letters.
- All are distinct.
Input
The input is given from Standard Input in the following format:
Output
If there are and that satisfy the condition in the problem statement, print Yes
; otherwise, print No
.
Sample Input 1
5
ab
ccef
da
a
fe
Sample Output 1
Yes
If we take , the concatenation of ab
and a
in this order is aba
, which is a palindrome, satisfying the condition.
Thus, print Yes
.
Here, we can also take , for which the concatenation of fe
and ccef
in this order is feccef
, satisfying the condition.
Sample Input 2
3
a
b
aba
Sample Output 2
No
No two distinct strings among , , and form a palindrome when concatenated. Thus, print No
.
Note that the and in the statement must be distinct.
Sample Input 3
2
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Sample Output 3
Yes
update @ 2024/3/10 08:40:40