欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1536A.Omkar and Bad Story
Omkar and Bad Story
Omkar has received a message from Anton saying "Your story for problem A is confusing. Just make a formal statement." Because of this, Omkar gives you an array of distinct integers. An array is called nice if for any two distinct elements of , appears in at least once. In addition, all elements in must be distinct. Can you add several (maybe, ) integers to to create a nice array of size at most ? If is already nice, you don't have to add any elements.
For example, array is nice, as , which appears in the array, and , which appears in the array, while array is not nice, as is not present in the array.
For integers and , if and otherwise.
Input
Each test contains multiple test cases. The first line contains (), the number of test cases. Description of the test cases follows.
The first line of each test case contains a single integer () — the length of the array .
The second line of each test case contains distinct integers () — the elements of the array .
Output
For each test case, output one line containing YES if Omkar can create a nice array by adding elements to and NO otherwise. The case of each letter does not matter, so yEs and nO will also be accepted.
If the first line is YES, output a second line containing a single integer ().
Then output one line containing distinct integers (), the elements of the nice array . can be in any order. For each in , must appear at least once in .
It can be proved that if Omkar can create such an array , then he can also do so in a way that satisfies the above constraints.
If multiple solutions exist, you can print any.
Note
For the first case, you can add integers to to receive the array . Note that and is in , and is in , and is in , so is nice.
For the second case, you can add integers to to receive the array . We have that is in , is in , is in , and is in , so is nice.
For the fourth case, you can add integers to to receive the array . We have that is in , is in , is in , is in , and is in , so is nice.
It can be proven that for all other test cases it is impossible to create a nice array .
Samples
4
3
3 0 9
2
3 4
5
-7 3 13 -2 8
4
4 8 12 6
yes
4
6 0 3 9
yEs
5
5 3 1 2 4
NO
Yes
6
8 12 6 2 4 10
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |