308298: CF1496A. Split it!

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Split it!

题意翻译

## 题目描述 给出一个长度为 $n$ 的字符串 $s$,再给定一个参数 $k$。 问是否存在字符串 $a_1,a_2,...,a_{k+1}$,使得: $$s=a_1+a_2+...+a_k+a_{k+1}+R(a_k)+...+R(a_2)+R(a_1)$$ 如果存在,输出 `YES`;否则输出 `NO`。 上式中 $+$ 为字符串拼接,$R(a_i)$ 为 $a_i$ 的反串。 **本题多测。** ## 输入格式 第一行 $t$ 表示数据组数。 对于每组数据: 第一行 $n,k$ 如题所述,第二行一个字符串 $s$。 ## 输出格式 共 $t$ 行,第 $i$ 行为第 $i$ 组数据。 对于第 $i$ 组数据,如果 $s$ 满足题意条件,输出 `YES`;否则输出 `NO`。 ## 数据范围 $1 \leq n \leq 100,0 \leq k \leq \left\lfloor\dfrac{n}{2}\right\rfloor$

题目描述

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 $ s $ and a parameter $ k $ , you need to check if there exist $ k+1 $ non-empty strings $ a_1,a_2...,a_{k+1} $ , such that $ s=a_1+a_2+\ldots +a_k+a_{k+1}+R(a_k)+R(a_{k-1})+\ldots+R(a_{1}). $ Here $ + $ represents concatenation. We define $ R(x) $ as a reversed string $ x $ . For example $ R(abcd) = dcba $ . Note that in the formula above the part $ R(a\_{k+1})$ is intentionally skipped.

输入输出格式

输入格式


The input consists of multiple test cases. The first line contains a single integer $ t $ ( $ 1\le t\le 100 $ ) — the number of test cases. The description of the test cases follows. The first line of each test case description contains two integers $ n $ , $ k $ ( $ 1\le n\le 100 $ , $ 0\le k\le \lfloor \frac{n}{2} \rfloor $ ) — the length of the string $ s $ and the parameter $ k $ . The second line of each test case description contains a single string $ s $ of length $ n $ , consisting of lowercase English letters.

输出格式


For each test case, print "YES" (without quotes), if it is possible to find $ a_1,a_2,\ldots,a_{k+1} $ , and "NO" (without quotes) otherwise. You can print letters in any case (upper or lower).

输入输出样例

输入样例 #1

7
5 1
qwqwq
2 1
ab
3 1
ioi
4 2
icpc
22 0
dokidokiliteratureclub
19 8
imteamshanghaialice
6 3
aaaaaa

输出样例 #1

YES
NO
YES
NO
YES
NO
NO

说明

In the first test case, one possible solution is $ a_1=qw $ and $ a_2=q $ . In the third test case, one possible solution is $ a_1=i $ and $ a_2=o $ . In the fifth test case, one possible solution is $ a_1=dokidokiliteratureclub $ .

Input

题意翻译

## 题目描述 给出一个长度为 $n$ 的字符串 $s$,再给定一个参数 $k$。 问是否存在字符串 $a_1,a_2,...,a_{k+1}$,使得: $$s=a_1+a_2+...+a_k+a_{k+1}+R(a_k)+...+R(a_2)+R(a_1)$$ 如果存在,输出 `YES`;否则输出 `NO`。 上式中 $+$ 为字符串拼接,$R(a_i)$ 为 $a_i$ 的反串。 **本题多测。** ## 输入格式 第一行 $t$ 表示数据组数。 对于每组数据: 第一行 $n,k$ 如题所述,第二行一个字符串 $s$。 ## 输出格式 共 $t$ 行,第 $i$ 行为第 $i$ 组数据。 对于第 $i$ 组数据,如果 $s$ 满足题意条件,输出 `YES`;否则输出 `NO`。 ## 数据范围 $1 \leq n \leq 100,0 \leq k \leq \left\lfloor\dfrac{n}{2}\right\rfloor$

加入题单

算法标签: