CF1419C.Killjoy
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).
Killjoy's account is already infected and has a rating equal to x. Its rating is constant. There are n accounts except hers, numbered from 1 to n. The i-th account's initial rating is ai. Any infected account (initially the only infected account is Killjoy's) instantly infects any uninfected account if their ratings are equal. This can happen at the beginning (before any rating changes) and after each contest. If an account is infected, it can not be healed.
Contests are regularly held on Codeforces. In each contest, any of these n accounts (including infected ones) can participate. Killjoy can't participate. After each contest ratings are changed this way: each participant's rating is changed by an integer, but the sum of all changes must be equal to zero. New ratings can be any integer.
Find out the minimal number of contests needed to infect all accounts. You can choose which accounts will participate in each contest and how the ratings will change.
It can be proven that all accounts can be infected in some finite number of contests.
一名名为“Killjoy”的新特工发明了一种名为 COVID-2069 的病毒,该病毒会感染 Codeforces 上的账户。每个账户都有一个用整数表示的评分(该整数可能为负数,也可能非常大)。
Killjoy 自己的账户已被感染,其评分为 x,且该评分恒定不变。除她之外还有 n 个账户,编号从 1 到 n。第 i 个账户的初始评分为 ai。任意已被感染的账户(最初仅有 Killjoy 的账户被感染)会立即感染所有未被感染且评分与其相等的账户。这种感染可在初始时刻(即任何评分变更发生前)以及每次比赛后即时发生。一旦账户被感染,便无法恢复健康。
Codeforces 定期举办比赛。在每场比赛中,上述 n 个账户中的任意一个(包括已被感染的账户)均可参赛,但 Killjoy 本人不能参赛。每场比赛结束后,所有参赛者的评分将按如下方式变更:每位参赛者的评分变化量均为整数,且所有参赛者评分变化量之和必须为零。变更后的评分可以是任意整数。
请确定感染全部 n 个账户所需的最少比赛场数。你可以自由决定每场比赛中哪些账户参赛,以及各参赛者评分的具体变化量。
可以证明:总存在某个有限的比赛场数,使得所有账户均被感染。
输入格式
The first line contains a single integer t (1≤t≤100) — the number of test cases. The next 2t lines contain the descriptions of all test cases.
The first line of each test case contains two integers n and x (2≤n≤103, −4000≤x≤4000) — the number of accounts on Codeforces and the rating of Killjoy's account.
The second line of each test case contains n integers a1,a2,…,an (−4000≤ai≤4000) — the ratings of other accounts.
第一行包含一个整数 t(1≤t≤100)—— 表示测试用例的数量。接下来的 2t 行包含所有测试用例的描述。
每个测试用例的第一行包含两个整数 n 和 x(2≤n≤103,−4000≤x≤4000)—— 分别表示 Codeforces 上的账号数量以及 Killjoy 账号的评分。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(−4000≤ai≤4000)—— 表示其余账号的评分。
输出格式
For each test case output the minimal number of contests needed to infect all accounts.
对于每个测试用例,输出感染所有账号所需的最少比赛场数。
输入输出样例
输入#1
3 2 69 68 70 6 4 4 4 4 4 4 4 9 38 -21 83 50 -59 -77 15 -71 -78 20
输出#1
1 0 2
说明/提示
In the first test case it's possible to make all ratings equal to 69. First account's rating will increase by 1, and second account's rating will decrease by 1, so the sum of all changes will be equal to zero.
In the second test case all accounts will be instantly infected, because all ratings (including Killjoy's account's rating) are equal to 4.
在第一个测试用例中,可以将所有评分变为 69。第一个账号的评分会增加 1,第二个账号的评分会减少 1,因此所有变化的总和为零。
在第二个测试用例中,所有账号会立即被感染,因为所有评分(包括 Killjoy 账号的评分)都等于 4。
输入解题思路,AI测评打分。不知道怎么写?