CF1504A.Déjà Vu
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A palindrome is a string that reads the same backward as forward. For example, the strings "z", "aaa", "aba", and "abccba" are palindromes, but "codeforces" and "ab" are not. You hate palindromes because they give you déjà vu.
There is a string s. You must insert exactly one character 'a' somewhere in s. If it is possible to create a string that is not a palindrome, you should find one example. Otherwise, you should report that it is impossible.
For example, suppose s= "cbabc". By inserting an 'a', you can create "acbabc", "cababc", "cbaabc", "cbabac", or "cbabca". However "cbaabc" is a palindrome, so you must output one of the other options.
回文是指正读和反读都相同的字符串。例如,字符串 "z"、"aaa"、"aba" 和 "abccba" 都是回文,但 "codeforces" 和 "ab" 不是。你讨厌回文,因为它们让你产生似曾相识的感觉。
给定一个字符串 s。你必须在 s 中的某个位置恰好插入一个字符 'a'。如果能够通过该操作得到一个非回文字符串,则你需要给出一个可行的例子;否则,请报告这是不可能的。
例如,假设 s= "cbabc"。通过插入一个 'a',你可以得到 "acbabc"、"cababc"、"cbaabc"、"cbabac" 或 "cbabca"。然而 "cbaabc" 是一个回文,因此你必须从其余选项中输出一个。
输入格式
The first line contains a single integer t (1≤t≤104) — the number of test cases.
The only line of each test case contains a string s consisting of lowercase English letters.
The total length of all strings does not exceed 3⋅105.
第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
每个测试用例仅有一行,包含一个由小写英文字母组成的字符串 s。
所有字符串的总长度不超过 3⋅105。
输出格式
For each test case, if there is no solution, output "NO".
Otherwise, output "YES" followed by your constructed string of length ∣s∣+1 on the next line. If there are multiple solutions, you may print any.
You can print each letter of "YES" and "NO" in any case (upper or lower).
对于每个测试用例,若无解,则输出 "NO"。
否则,先输出 "YES",然后在下一行输出你构造出的长度为 ∣s∣+1 的字符串。若存在多个解,输出任意一个即可。
"YES" 和 "NO" 中的每个字母均可使用大写或小写形式输出。
输入输出样例
输入#1
6 cbabc ab zza ba a nutforajaroftuna
输出#1
YES cbabac YES aab YES zaza YES baa NO YES nutforajarofatuna
说明/提示
The first test case is described in the statement.
In the second test case, we can make either "aab" or "aba". But "aba" is a palindrome, so "aab" is the only correct answer.
In the third test case, "zaza" and "zzaa" are correct answers, but not "azza".
In the fourth test case, "baa" is the only correct answer.
In the fifth test case, we can only make "aa", which is a palindrome. So the answer is "NO".
In the sixth test case, "anutforajaroftuna" is a palindrome, but inserting 'a' elsewhere is valid.
第一个测试用例已在题目描述中给出。
在第二个测试用例中,我们可以构造出 "aab" 或 "aba"。但 "aba" 是一个回文串,因此唯一正确的答案是 "aab"。
在第三个测试用例中,"zaza" 和 "zzaa" 都是正确答案,但 "azza" 不是。
在第四个测试用例中,"baa" 是唯一正确的答案。
在第五个测试用例中,我们只能构造出 "aa",而它是一个回文串。因此答案为 "NO"。
在第六个测试用例中,"anutforajaroftuna" 本身是一个回文串,但在其他位置插入字母 'a' 也是合法的。
输入解题思路,AI测评打分。不知道怎么写?