CF1766B.Notepad#

入门

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You want to type the string ss, consisting of nn 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 ss in strictly less than nn operations?

你想使用你最喜爱的文本编辑器 Notepad# 输入一个由 nn 个小写拉丁字母组成的字符串 ss。

Notepad# 支持两种操作:

  • 在字符串末尾追加任意一个字母;
  • 复制已输入字符串中某个连续子串,并将该子串粘贴到字符串末尾。

你能否在严格少于 nn 次操作内输入字符串 ss?

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of testcases.

The first line of each testcase contains a single integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the length of the string ss.

The second line contains a string ss, consisting of nn lowercase Latin letters.

The sum of nn doesn't exceed 2⋅1052 \cdot 10^5 over all testcases.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)——测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)——字符串 ss 的长度。

每个测试用例的第二行包含一个字符串 ss,由 nn 个小写拉丁字母组成。

所有测试用例中 nn 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

For each testcase, print "YES" if you can type string ss in strictly less than nn operations. Otherwise, print "NO".

对于每个测试用例,如果可以在严格少于 nn 次操作内输入字符串 ss,则输出 "YES";否则,输出 "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" (55 operations), then copy "o" (11 operation) from an already typed part, then finish with typing "rces" (44 operations). That will be 1010 operations, which is not strictly less than nn. There exist other ways to type "codeforces". However, no matter what you do, you can't do less than nn operations.

In the second testcase, you can type "labac" (55 operations), then copy "aba" (11 operation), finishing the string in 66 operations.

在第一个测试用例中,你可以先输入 “codef”(5 次操作),然后从已输入的部分中复制字符 “o”(1 次操作),最后输入 “rces”(4 次操作)。总共需要 1010 次操作,这并不严格小于 nn。虽然存在其他输入字符串 “codeforces” 的方法,但无论如何操作,你都无法少于 nn 次操作。

在第二个测试用例中,你可以先输入 “labac”(5 次操作),然后复制子串 “aba”(1 次操作),从而在 66 次操作内完成整个字符串。

输入解题思路,AI测评打分。不知道怎么写?

首页