CF1766B Notepad#

题目描述

一开始打出的内容为空。现在你要打出一个长度为 $n$ 的字符串 $s$(全为英文小写字母组成),为此每次你可以进行如下操作中的一种: - 在已打出内容的最后添加一个字符。 - 复制已打出内容的一个连续的子串并加到内容的末尾。 问你能不能在严格小于 $n$ 次操作下打出字符串 $s$?

输入格式

$t$ 组数据。第一行输入正整数 $t(1\le t\le10^4)$。 每组数据第一行输入正整数 $n$,第二行输入字符串 $s$。 单个测试点内所有 $n$ 之和不超过 $2\times10^5$。

输出格式

输出 $t$ 行,每行输出这组数据的答案。如果可以达到要求,输出 `YES`。否则输出 `NO`。

说明/提示

In the first testcase, you can start with typing "codef" ( $ 5 $ operations), then copy "o" ( $ 1 $ operation) from an already typed part, then finish with typing "rces" ( $ 4 $ operations). That will be $ 10 $ operations, which is not strictly less than $ n $ . There exist other ways to type "codeforces". However, no matter what you do, you can't do less than $ n $ operations. In the second testcase, you can type "labac" ( $ 5 $ operations), then copy "aba" ( $ 1 $ operation), finishing the string in $ 6 $ operations.