308342: CF1504A. Déjà Vu
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Déjà Vu
题意翻译
### 题目描述 定义一个回文串为正着读与倒着读都相同的字符串,比如 `z`,`aba` 和 `abccba` 都是回文串。你恨回文串因为它给你“既视感”。 现有一字符串 $s$,你必须插入恰好一个字母 `a` 在 $s$ 的某处。若操作后的新字符串可能**不是**回文串,你需要找到一个例子;反之,你需要报告这是不可能的 比如,假设 $s$ 为 `cbabc`,通过插入一个字母 `a`,可以得到 `acbabc`、`cababc`、`cbaabc`、`cbabac`、或 `cbabca`。然而,`cbaabc` 是回文串,所以你应当输出其它字符串中的一个。 ### 输入格式 第 $1$ 行一个整数 $t$,代表 $t$ 组测试数据 第 $2$ 行至第 $n+1$ 行,每行一个字符串 ### 输出格式 对于每个字符串 - 若不可能使新字符串不是回文串,输出 `NO` - 反之,输出 `YES`,换行并举出一例 换行 `YES` 与 `NO` 可以是小写或大写 ### 数据范围 $1 \leq t \leq 10^4$ 字符串总长度不超过 $3 \times 10^5$题目描述
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.输入输出格式
输入格式
The first line contains a single integer $ t $ ( $ 1\le t\le 10^4 $ ) — 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\cdot 10^5 $ .
输出格式
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).
输入输出样例
输入样例 #1
6
cbabc
ab
zza
ba
a
nutforajaroftuna
输出样例 #1
YES
cbabac
YES
aab
YES
zaza
YES
baa
NO
YES
nutforajarofatuna