CF2160A.MEX Partition

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Let a partition of a multiset BB be a collection of multisets s1,s2,…,sks_1, s_2,\ldots, s_k such that each element appears the same number of times in BB and across all of s1,s2,…,sks_1,s_2,\ldots,s_k.

For example, some partitions of 1,2,3,3{1,2,3,3} include 1,3+2,3,1,2,3,3{1,3}+{2,3}, {1,2,3,3}, and 2+1,3+3{2}+{1,3}+{3}, but not 1,2+3{1,2}+{3}.

A partition is called valid if the mex⁡\operatorname{mex}∗^{\text{∗}} of all multisets in the partition is the same. The score of a valid partition is the mex⁡\operatorname{mex} of any multiset in the partition.

You are given a multiset AA of size nn. Find the minimum score over all valid partitions of AA.

∗^{\text{∗}}The minimum excluded (MEX) of a collection of integers c1,c2,…,ckc_1, c_2, \ldots, c_k is defined as the smallest non-negative integer xx which does not occur in the collection cc.

设多重集 BB 的一个划分为若干多重集 s1,s2,…,sks_1, s_2,\ldots, s_k 构成的集合,使得每个元素在 BB 中出现的次数与在所有 s1,s2,…,sks_1,s_2,\ldots,s_k 中出现的总次数相等。

例如,多重集 {1,2,3,3}\{1,2,3,3\} 的一些划分包括 {1,3}+{2,3}\{1,3\}+\{2,3\}、{1,2,3,3}\{1,2,3,3\} 和 {2}+{1,3}+{3}\{2\}+\{1,3\}+\{3\},但 {1,2}+{3}\{1,2\}+\{3\} 不是其划分。

若一个划分中所有多重集的 mex⁡\operatorname{mex}∗^{\text{∗}} 均相等,则称该划分是有效的。一个有效划分的得分定义为其中任意一个多重集的 mex⁡\operatorname{mex} 值。

给定一个大小为 nn 的多重集 AA,求 AA 的所有有效划分中的最小得分。

∗^{\text{∗}} 一组整数 c1,c2,…,ckc_1, c_2, \ldots, c_k 的最小未出现值(MEX) 定义为不在该集合中出现的最小非负整数 xx。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1001 \le t \le 100). The description of the test cases follows.

The first line of each test case contains an integer nn (1≤n≤1001 \leq n \leq 100).

The second line contains nn integers A1,A2,…,AnA_1, A_2, \ldots, A_n denoting the elements of AA (0≤Ai≤1000 \leq A_i \leq 100).

It is not guaranteed that the elements are given in non-decreasing order.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1001 \le t \le 100)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \leq n \leq 100)。

第二行包含 nn 个整数 A1,A2,…,AnA_1, A_2, \ldots, A_n,表示数组 AA 的元素(0≤Ai≤1000 \leq A_i \leq 100)。

不保证这些元素以非递减顺序给出。

输出格式

For each test case, output the minimum score over all valid partitions.

对于每个测试用例,输出所有有效划分中的最小得分。

输入输出样例

  • 输入#1

    2
    3
    0 0 0
    2
    1 2

    输出#1

    1
    0

说明/提示

In the first test case, the minimum score of 11 can be obtained by the partition 0+0+0{0}+{0}+{0}. The partition is valid because each multiset has a mex⁡\operatorname{mex} of 11, which is consequently the score of the partition.

In the second test case, we can use 1,2{1,2} as the only multiset in the partition, which has mex⁡0\operatorname{mex} 0.

在第一个测试用例中,通过划分 {0}+{0}+{0}\{0\}+\{0\}+\{0\} 可以得到最小得分 11。该划分是合法的,因为每个多重集的 mex⁡\operatorname{mex} 均为 11,因此该划分的得分为 11。

在第二个测试用例中,我们可以将 {1,2}\{1,2\} 作为划分中唯一的多重集,其 mex⁡\operatorname{mex} 为 00。

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

首页