309973: CF1766B. Notepad#

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

Description

Notepad#

题意翻译

### 题目描述 一开始打出的内容为空。现在你要打出一个长度为 $n$ 的字符串 $s$(全为英文小写字母组成),为此每次你可以进行如下操作中的一种: - 在已打出内容的最后添加一个字符。 - 复制已打出内容的一个连续的子串并加到内容的末尾。 问你能不能在严格小于 $n$ 次操作下打出字符串 $s$? ### 输入格式 $t$ 组数据。第一行输入正整数 $t(1\le t\le10^4)$。 每组数据第一行输入正整数 $n$,第二行输入字符串 $s$。 单个测试点内所有 $n$ 之和不超过 $2\times10^5$。 ### 输出格式 输出 $t$ 行,每行输出这组数据的答案。如果可以达到要求,输出 `YES`。否则输出 `NO`。

题目描述

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 \le t \le 10^4 $ ) — the number of testcases. The first line of each testcase contains a single integer $ n $ ( $ 1 \le n \le 2 \cdot 10^5 $ ) — 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 \cdot 10^5 $ 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.

Input

题意翻译

### 题目描述 一开始打出的内容为空。现在你要打出一个长度为 $n$ 的字符串 $s$(全为英文小写字母组成),为此每次你可以进行如下操作中的一种: - 在已打出内容的最后添加一个字符。 - 复制已打出内容的一个连续的子串并加到内容的末尾。 问你能不能在严格小于 $n$ 次操作下打出字符串 $s$? ### 输入格式 $t$ 组数据。第一行输入正整数 $t(1\le t\le10^4)$。 每组数据第一行输入正整数 $n$,第二行输入字符串 $s$。 单个测试点内所有 $n$ 之和不超过 $2\times10^5$。 ### 输出格式 输出 $t$ 行,每行输出这组数据的答案。如果可以达到要求,输出 `YES`。否则输出 `NO`。

Output

题目大意:
你想要使用你最喜欢的文本编辑器Notepad#打出由n个小写英文字母组成的字符串s。Notepad#支持两种操作:在字符串末尾添加任意字母;复制已打出字符串中的一个连续子串并将其粘贴到字符串末尾。问你是否可以在严格小于n次操作内打出字符串s?

输入数据格式:
第一行包含一个整数t(1≤t≤10^4),表示测试用例的数量。
每个测试用例的第一行包含一个整数n(1≤n≤2×10^5),表示字符串s的长度。
第二行包含一个由n个小写英文字母组成的字符串s。
所有测试用例的n之和不超过2×10^5。

输出数据格式:
对于每个测试用例,如果你可以在严格小于n次操作内打出字符串s,则输出"YES"。否则,输出"NO"。

输入输出样例:
输入样例 #1:
```
6
10
codeforces
8
labacaba
5
uohhh
16
isthissuffixtree
1
x
4
momo
```
输出样例 #1:
```
NO
YES
NO
YES
NO
YES
```

说明:
在第一个测试用例中,你可以先打出"codef"(5次操作),然后从已打出的部分复制"o"(1次操作),最后打出"rces"(4次操作)。这将需要10次操作,并不严格小于n。虽然存在其他打出"codeforces"的方式,但无论你做什么,你都不能少于n次操作。

在第二个测试用例中,你可以先打出"labac"(5次操作),然后复制"aba"(1次操作),最后在6次操作内完成字符串。题目大意: 你想要使用你最喜欢的文本编辑器Notepad#打出由n个小写英文字母组成的字符串s。Notepad#支持两种操作:在字符串末尾添加任意字母;复制已打出字符串中的一个连续子串并将其粘贴到字符串末尾。问你是否可以在严格小于n次操作内打出字符串s? 输入数据格式: 第一行包含一个整数t(1≤t≤10^4),表示测试用例的数量。 每个测试用例的第一行包含一个整数n(1≤n≤2×10^5),表示字符串s的长度。 第二行包含一个由n个小写英文字母组成的字符串s。 所有测试用例的n之和不超过2×10^5。 输出数据格式: 对于每个测试用例,如果你可以在严格小于n次操作内打出字符串s,则输出"YES"。否则,输出"NO"。 输入输出样例: 输入样例 #1: ``` 6 10 codeforces 8 labacaba 5 uohhh 16 isthissuffixtree 1 x 4 momo ``` 输出样例 #1: ``` NO YES NO YES NO YES ``` 说明: 在第一个测试用例中,你可以先打出"codef"(5次操作),然后从已打出的部分复制"o"(1次操作),最后打出"rces"(4次操作)。这将需要10次操作,并不严格小于n。虽然存在其他打出"codeforces"的方式,但无论你做什么,你都不能少于n次操作。 在第二个测试用例中,你可以先打出"labac"(5次操作),然后复制"aba"(1次操作),最后在6次操作内完成字符串。

加入题单

算法标签: