Constructive Problem

题意翻译

### 题目描述 给定整数 $n$ 和一个非负整数序列 $a$。 对于非负整数序列 $c$,记 $\text{MEX}(c)$ 表示**不存在**于 $c$ 中的最小非负整数。 记初始时 $m=\text{MEX}(a)$。 你需要进行下列操作恰好一次: - 选择整数 $l,r,k(1\leq l\leq r\leq n;0\leq k)$,然后将 $a_l,a_{l+1},\cdots,a_r$ 的值均变为 $k$。 判断能否通过恰好一次上述操作使操作后的 $a$ 满足 $\text{MEX}(a)=m+1$。 能输出 `Yes`,不能输出 `No`。 每个测试点包含 $t$ 组数据。 ### 输入格式 第一行输入一个整数 $t(1\leq t\leq5\times10^4)$ 表示数据组数,接下来对于每组数据: 第一行输入一个整数 $n(1\leq n,\sum n\leq2\times10^5)$。 接下来输入一行 $n$ 个整数 $a_1,a_2,\cdots,a_n(0\leq a_i\leq10^9)$。 ### 输出格式 对于每组数据: 如果能通过一次操作满足要求,输出 `Yes`;否则输出 `No`。 实际评测时校验器对大小写不敏感。 ### 样例解释 对于第一组数据: - 初始 $m=0$。 你可以选择 $l=1,r=3,k=0$,此后 $a=[0,0,0],\text{MEX}(a)=1=m+1$。 因此可以通过一次操作达成要求,答案为 `Yes`。 对于第二组数据: - 初始 $m=1$。 你可以选择 $l=2,r=3,k=1$,此后 $a=[0,1,1,0],\text{MEX}(a)=2=m+1$。 因此可以通过一次操作达成要求,答案为 `Yes`。 可以证明,在第三组和第四组数据中,我们不能通过一次操作达成要求,因此这两组数据的答案为 `No`。

题目描述

As you know, any problem that does not require the use of complex data structures is considered constructive. You are offered to solve one of such problems. You are given an array $ a $ of $ n $ non-negative integers. You are allowed to perform the following operation exactly once: choose some non-empty subsegment $ a_l, a_{l+1}, \ldots, a_r $ of the array $ a $ and a non-negative integer $ k $ , and assign value $ k $ to all elements of the array on the chosen subsegment. The task is to find out whether $ \operatorname{MEX}(a) $ can be increased by exactly one by performing such an operation. In other words, if before the operation $ \operatorname{MEX}(a) = m $ held, then after the operation it must hold that $ \operatorname{MEX}(a) = m + 1 $ . Recall that $ \operatorname{MEX} $ of a set of integers $ c_1, c_2, \ldots, c_k $ is defined as the smallest non-negative integer $ x $ which does not occur in the set $ c $ .

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 50\,000 $ ) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $ n $ ( $ 1 \le n \le 200\,000 $ ) — the number of elements of array $ a $ . The second line of each test case contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 0 \le a_i \le 10^9 $ ) — elements of array $ a $ . It is guaranteed that the sum $ n $ over all test cases does not exceed $ 200\,000 $ .

输出格式


For each test case, print "Yes" if you can increase $ \operatorname{MEX}(a) $ by exactly one by performing the operation from the statement exactly once, otherwise print "No". You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

输入输出样例

输入样例 #1

4
3
1 2 1
4
0 2 2 0
4
3 2 0 2
1
0

输出样例 #1

Yes
Yes
No
No

说明

In the first test case, $ \operatorname{MEX}(a) = 0 $ . If you set all elements of $ a $ to $ 0 $ , then $ \operatorname{MEX} $ of the resulting array will be $ 1 $ , and thus will increase by one. In the second test case, $ \operatorname{MEX}(a) = 1 $ . If we assign a value of $ 1 $ to the elements of $ a $ on a subsegment from $ 2 $ to $ 3 $ , we get an array $ [0, 1, 1, 0] $ for which $ \operatorname{MEX} $ is $ 2 $ , and thus is increased by one compared to the original. It can be shown that in the third and fourth test cases it is impossible to perform an operation so that the value of $ \operatorname{MEX}(a) $ increases by exactly one.