

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
英小文字からなる長さ の文字列 と正整数 が与えられます。
以下の条件を満たす長さ の文字列 が存在するか判定してください。
- をこの順に結合して得られる文字列は回文である
- をこの順に結合して得られる文字列は回文である
個のテストケースが与えられるのでそれぞれについて判定してください。
制約
- は英小文字からなる長さ の文字列
- 入力される数値はすべて整数
- つの入力に含まれるテストケースについて、 の総和は 以下
入力
入力は以下の形式で標準入力から与えられます。
各ケースは以下の形式で与えられます。
出力
行出力せよ。 行目には 番目のテストケースについて、条件を満たす文字列 が存在する場合は Yes
を、存在しない場合は No
を出力せよ。
入力例 1Copy
2 6 2 abbaab 5 3 abcbb
出力例 1Copy
Yes No
番目のテストケースについて、例えば ba
とすると をこの順に結合して得られる文字列 abbaabba
は回文になっています。また、 をこの順に結合して得られる文字列 baabbaab
も回文になっています。以上より ba
は条件を満たすので答えは Yes
になります。
番目のテストケースについては、条件を満たす が存在しないことが証明できます。
入力例 2Copy
3 12 400378271514996652 njvhhvjnnjvh 10 884633988115575508 rrhiyvrrur 36 71630165869626180 vsxmxajrrduhhudrrjaxmxsvvsxmxajrrduh
出力例 2Copy
Yes No Yes
Score : points
Problem Statement
You are given a string of length consisting of lowercase English letters, and a positive integer .
Determine whether there is a string of length that satisfies the following conditions.
- The concatenation of and in this order is a palindrome.
- The concatenation of and in this order is a palindrome.
You have test cases to solve.
Constraints
- is a string of length consisting of lowercase English letters.
- All numbers in the input are integers.
- In each input file, the sum of over the test cases is at most .
Input
The input is given from Standard Input in the following format:
Each case is in the following format:
Output
Print lines. The -th line should contain Yes
if there is a string that satisfies the conditions for the -th test case, and No
otherwise.
Sample Input 1Copy
2 6 2 abbaab 5 3 abcbb
Sample Output 1Copy
Yes No
For the first test case, if we let ba
, for instance, the concatenation of and in this order will be abbaabba
, which is a palindrome. Here, the concatenation of and in this order is baabbaab
, which is also a palindrome. Thus, ba
satisfies the condition, so the answer is Yes
.
For the second test case, we can prove that no string satisfies the conditions.
Sample Input 2Copy
3 12 400378271514996652 njvhhvjnnjvh 10 884633988115575508 rrhiyvrrur 36 71630165869626180 vsxmxajrrduhhudrrjaxmxsvvsxmxajrrduh
Sample Output 2Copy
Yes No Yes