欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1909A.Distinct Buttons
Distinct Buttons
You are located at the point of an infinite Cartesian plane. You have a controller with buttons which can perform one of the following operations:
U: move from to ;R: move from to ;D: move from to ;L: move from to .
Unfortunately, the controller is broken. If you press all the buttons (in any order), the controller stops working. It means that, during the whole trip, you can only press at most distinct buttons (any number of times, in any order).
There are special points in the plane, with integer coordinates .
Can you visit all the special points (in any order) without breaking the controller?
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the number of special points.
Each of the next lines contains two integers , (), which represent the special point .
Note that there are no constraints on the sum of over all test cases.
Output
For each test case, output "YES" (without quotes), if you can reach all the special points without breaking the controller, and "NO" (without quotes) otherwise.
You may output each letter in any case (for example, "YES", "Yes", "yes", "yEs" will all be recognized as positive answer).
Note
In the first test case, you can move as follows:
- you start from ;
- you visit the special point ;
- you press
R, and you move from to ; - you press
D, and you move from to ; - you visit the special point ;
- you visit the special point .
Therefore, you can visit all the special points using only the buttons R, D, so the controller does not break.
Note that the special points may coincide.
In the second test case, you can show that you can visit all the special points using only the buttons U, D, L.
In the third test case, you can show that you must press all the buttons (U, R, D, L) to visit all the points, so the controller would break.
Samples
6
3
1 -1
0 0
1 -1
4
-3 -2
-3 -1
-3 0
-3 1
4
1 1
-1 -1
1 -1
-1 1
6
-4 14
-9 -13
-14 5
14 15
-8 -4
19 9
6
82 64
39 91
3 46
87 83
74 21
7 25
1
100 -100
YES
YES
NO
NO
YES
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |