308440: CF1520A. Do Not Be Distracted!
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Do Not Be Distracted!
题意翻译
### 题目描述 Polycarp 有 $26$ 个任务。每一个任务都由一个大写字母来决定。 老师让 Polycarp 按以下规则做任务:如果 Polycarp 开始做某些任务,那么他必须一直做它,期间不能做其它任务,直到切换任务。但在切换到另一个任务之后,Polycarp 就不能再回到以前做过的任务了。 Polycarp 只能在一天内做一个任务。每一天他会写下他做了什么任务。现在老师想知道 Polycarp 是否遵守了他的规则。 举个例子,如果 Polycarp 以`DDBBCCCBBEZ`的顺序来做任务,那么老师就会知道在第三天 Polycarp 开始做任务`B`,然后在第五天他转移到做任务`C`,在第八天 Polycarp 又回到了做任务`B`,不符合老师的规则,老师就会怀疑他。老师会怀疑的的另外的例子有:`BAB`、`AABBCCDDEEBZZ`和`AAAAZAAAAA`。 如果 Polycarp 按照 `FFGZZZY` 的顺序来做,那么老师就没有任何怀疑。请注意 Polycarp 不必须完成所有的 $26$ 个任务。老师不会怀疑的其它例子有:`BA`、`AFFFCC`和`YYYYY`。 请你帮 Polycarp 指出他的老师是否会怀疑他。 ### 输入格式 第一行有一个整数 $t$($1\leq t\leq1000$),表示数据组数。接下来分别输入这 $t$ 组数据。 对于每一组数据,第一行一个整数 $n$($1\leq n\leq50$),表示 Polycarp 花了几天做任务。 第二行为一个长度为 $n$ 的字符串,只包括大写的字母,表示 Polycarp 每天做的任务。 ### 输出格式 对于每一组数据输出: - `YES`,表示老师不会怀疑 Polycarp。 - 否则,输出 `NO`。 你可以以任意的方式输出字母(例如,`yEs`、`yes`、`Yes`和`YES`都表示老师不会怀疑)。题目描述
Polycarp has $ 26 $ tasks. Each task is designated by a capital letter of the Latin alphabet. The teacher asked Polycarp to solve tasks in the following way: if Polycarp began to solve some task, then he must solve it to the end, without being distracted by another task. After switching to another task, Polycarp cannot return to the previous task. Polycarp can only solve one task during the day. Every day he wrote down what task he solved. Now the teacher wants to know if Polycarp followed his advice. For example, if Polycarp solved tasks in the following order: "DDBBCCCBBEZ", then the teacher will see that on the third day Polycarp began to solve the task 'B', then on the fifth day he got distracted and began to solve the task 'C', on the eighth day Polycarp returned to the task 'B'. Other examples of when the teacher is suspicious: "BAB", "AABBCCDDEEBZZ" and "AAAAZAAAAA". If Polycarp solved the tasks as follows: "FFGZZZY", then the teacher cannot have any suspicions. Please note that Polycarp is not obligated to solve all tasks. Other examples of when the teacher doesn't have any suspicious: "BA", "AFFFCC" and "YYYYY". Help Polycarp find out if his teacher might be suspicious.输入输出格式
输入格式
The first line contains an integer $ t $ ( $ 1 \le t \le 1000 $ ). Then $ t $ test cases follow. The first line of each test case contains one integer $ n $ ( $ 1 \le n \le 50 $ ) — the number of days during which Polycarp solved tasks. The second line contains a string of length $ n $ , consisting of uppercase Latin letters, which is the order in which Polycarp solved the tasks.
输出格式
For each test case output: - "YES", if the teacher cannot be suspicious; - "NO", otherwise. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).
输入输出样例
输入样例 #1
5
3
ABA
11
DDBBCCCBBEZ
7
FFGZZZY
1
Z
2
AB
输出样例 #1
NO
NO
YES
YES
YES