CF1766B.Notepad#
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You want to type the string s , consisting of n lowercase Latin letters, using your favorite text editor Notepad#.
Notepad# supports two kinds of operations:
- append any letter to the end of the string;
- copy a continuous substring of an already typed string and paste this substring to the end of the string.
Can you type string s in strictly less than n operations?
输入格式
The first line contains a single integer t ( 1≤t≤104 ) — the number of testcases.
The first line of each testcase contains a single integer n ( 1≤n≤2⋅105 ) — the length of the string s .
The second line contains a string s , consisting of n lowercase Latin letters.
The sum of n doesn't exceed 2⋅105 over all testcases.
输出格式
For each testcase, print "YES" if you can type string s in strictly less than n operations. Otherwise, print "NO".
输入输出样例
输入#1
6 10 codeforces 8 labacaba 5 uohhh 16 isthissuffixtree 1 x 4 momo
输出#1
NO YES NO YES NO YES
说明/提示
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.