CF1909A.Distinct Buttons
普及/提高-
通过率:0%

AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
⠀
You are located at the point (0,0) of an infinite Cartesian plane. You have a controller with 4 buttons which can perform one of the following operations:
- U : move from (x,y) to (x,y+1) ;
- R : move from (x,y) to (x+1,y) ;
- D : move from (x,y) to (x,y−1) ;
- L : move from (x,y) to (x−1,y) .
Unfortunately, the controller is broken. If you press all the 4 buttons (in any order), the controller stops working. It means that, during the whole trip, you can only press at most 3 distinct buttons (any number of times, in any order).
There are n special points in the plane, with integer coordinates (xi,yi) .
Can you visit all the special points (in any order) without breaking the controller?
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤1000 ). The description of the test cases follows.
The first line of each test case contains a single integer n ( 1≤n≤100 ) — the number of special points.
Each of the next n lines contains two integers xi , yi ( −100≤xi,yi≤100 ), which represent the special point (xi,yi) .
Note that there are no constraints on the sum of n over all test cases.
输出格式
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).
输入输出样例
输入#1
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
输出#1
YES YES NO NO YES YES
说明/提示
In the first test case, you can move as follows:
- you start from (0,0) ;
- you visit the special point (x2,y2)=(0,0) ;
- you press R , and you move from (0,0) to (1,0) ;
- you press D , and you move from (1,0) to (1,−1) ;
- you visit the special point (x1,y1)=(1,−1) ;
- you visit the special point (x3,y3)=(1,−1) .
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.