A15662 | Notepad#
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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.
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.
In the second testcase, you can type "labac" ( $5$ operations), then copy "aba" ( $1$ operation), finishing the string in $6$ operations.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted