A13851 | Killjoy
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $a_i$ . 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'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 $a_i$ . 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.
输入格式
The first line contains a single integer $t$ $(1 \le t \le 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 \le n \le 10^3$ , $-4000 \le x \le 4000$ ) — the number of accounts on Codeforces and the rating of Killjoy's account.
The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ $(-4000 \le a_i \le 4000)$ — the ratings of other accounts.
The first line of each test case contains two integers $n$ and $x$ ( $2 \le n \le 10^3$ , $-4000 \le x \le 4000$ ) — the number of accounts on Codeforces and the rating of Killjoy's account.
The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ $(-4000 \le a_i \le 4000)$ — the ratings of other accounts.
输出格式
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$ .
In the second test case all accounts will be instantly infected, because all ratings (including Killjoy's account's rating) are equal to $4$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted