0% found this document useful (0 votes)
34 views

Code 10

Kawashiro Nitori enjoys creating programming problems. She devised a problem where given a string S and integer K, you must determine if S can be divided into K+1 non-empty strings that when concatenated and reversed satisfy a specified formula. The input consists of multiple test cases with the string length N and parameter K, followed by the string S. For each case, the output is "YES" if the strings can be found or "NO" if not.

Uploaded by

Md.Amdad Hossain
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Code 10

Kawashiro Nitori enjoys creating programming problems. She devised a problem where given a string S and integer K, you must determine if S can be divided into K+1 non-empty strings that when concatenated and reversed satisfy a specified formula. The input consists of multiple test cases with the string length N and parameter K, followed by the string S. For each case, the output is "YES" if the strings can be found or "NO" if not.

Uploaded by

Md.Amdad Hossain
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Kawashiro Nitori is a girl who loves competitive programming.

One day she found a string and an integer. As an advanced problem setter, she quickly thought of a
problem.
Given a string ss and a parameter kk, you need to check if there exist k+1k+1 non-empty
strings a1,a2...,ak+1a1,a2...,ak+1, such that
s=a1+a2+…+ak+ak+1+R(ak)+R(ak−1)+…+R(a1).s=a1+a2+…+ak+ak+1+R(ak)+R(ak−1)+
…+R(a1).

Here ++ represents concatenation. We define R(x)R(x) as a reversed string xx. For


example R(abcd)=dcbaR(abcd)=dcba. Note that in the formula above the part R(ak+1)R(ak+1) is
intentionally skipped.
Input
The input consists of multiple test cases. The first line contains a single
integer tt (1≤t≤1001≤t≤100)  — the number of test cases. The description of the test cases follows.
The first line of each test case description contains two
integers nn, kk (1≤n≤1001≤n≤100, 0≤k≤⌊n2⌋0≤k≤⌊n2⌋)  — the length of the string ss and the
parameter kk.
The second line of each test case description contains a single string ss of length nn, consisting of
lowercase English letters.
Output
For each test case, print "YES" (without quotes), if it is possible to find a1,a2,…,ak+1a1,a2,…,ak+1,
and "NO" (without quotes) otherwise.

You can print letters in any case (upper or lower).

You might also like