欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1927C.Choose the Different Ones!
Choose the Different Ones!
Given an array of integers, an array of integers, and an even number .
Your task is to determine whether it is possible to choose exactly elements from both arrays in such a way that among the chosen elements, every integer from to is included.
For example:
- If , , , then it is possible to choose elements with values from array and elements with values from array . In this case, all numbers from to will be included among the chosen elements.
- If , , , then it is not possible to choose elements in the required way.
Note that you are not required to find a way to choose the elements — your program should only check whether it is possible to choose the elements in the required way.
Input
The first line of the input contains a single integer () — the number of test cases. The descriptions of the test cases follow.
The first line of each test case contains three integers , , and (, , is even) — the length of array , the length of array , and the number of elements to be chosen, respectively.
The second line of each test case contains integers () — the elements of array .
The third line of each test case contains integers () — the elements of array .
It is guaranteed that the sum of values and over all test cases in a test does not exceed .
Output
Output lines, each of which is the answer to the corresponding test case. As the answer, output "YES" if it is possible to choose numbers from each array in such a way that among the chosen elements, every integer from to is included. Otherwise, output "NO".
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
Note
In the first test case of the example, it is possible to choose elements equal to , , and from array and elements equal to , , and from array . Thus, all numbers from to are included among the chosen elements.
In the second test case of the example, it can be shown that it is not possible to choose exactly three elements from each array in the required way.
In the third test case of the example, it is possible to choose elements equal to and from array and elements equal to and from array . Thus, all numbers from to are included among the chosen elements.
Samples
6
6 5 6
2 3 8 5 6 5
1 3 4 10 5
6 5 6
2 3 4 5 6 5
1 3 8 10 3
3 3 4
1 3 5
2 4 6
2 5 4
1 4
7 3 4 4 2
1 4 2
2
6 4 4 2
1 5 2
3
2 2 1 4 3
YES
NO
YES
YES
NO
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |