CF1909A.Distinct Buttons

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Deemo - Entrance

⠀

You are located at the point (0,0)(0, 0) of an infinite Cartesian plane. You have a controller with 44 buttons which can perform one of the following operations:

  • U\texttt{U}: move from (x,y)(x, y) to (x,y+1)(x, y+1);
  • R\texttt{R}: move from (x,y)(x, y) to (x+1,y)(x+1, y);
  • D\texttt{D}: move from (x,y)(x, y) to (x,y−1)(x, y-1);
  • L\texttt{L}: move from (x,y)(x, y) to (x−1,y)(x-1, y).

Unfortunately, the controller is broken. If you press all the 44 buttons (in any order), the controller stops working. It means that, during the whole trip, you can only press at most 33 distinct buttons (any number of times, in any order).

There are nn special points in the plane, with integer coordinates (xi,yi)(x_i, y_i).

Can you visit all the special points (in any order) without breaking the controller?

Deemo - 入口

⠀

你位于无限笛卡尔平面的点 (0,0)(0, 0) 处。你手中有一个带有 44 个按钮的控制器,每个按钮可执行以下操作之一:

  • U\texttt{U}:从 (x,y)(x, y) 移动到 (x,y+1)(x, y+1);
  • R\texttt{R}:从 (x,y)(x, y) 移动到 (x+1,y)(x+1, y);
  • D\texttt{D}:从 (x,y)(x, y) 移动到 (x,y−1)(x, y-1);
  • L\texttt{L}:从 (x,y)(x, y) 移动到 (x−1,y)(x-1, y)。

不幸的是,该控制器已损坏:若你按下了全部 44 个按钮(顺序任意),控制器便会停止工作。这意味着,在整个行程中,你最多只能使用其中 33 个不同的按钮(每个可用任意次数,且顺序任意)。

平面上有 nn 个特殊点,其坐标 (xi,yi)(x_i, y_i) 均为整数。

你能否在不损坏控制器的前提下访问所有特殊点(访问顺序任意)?

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤10001 \le t \le 1000). The description of the test cases follows.

The first line of each test case contains a single integer nn (1≤n≤1001 \le n \le 100) — the number of special points.

Each of the next nn lines contains two integers xix_i, yiy_i (−100≤xi,yi≤100-100 \leq x_i, y_i \leq 100), which represent the special point (xi,yi)(x_i, y_i).

Note that there are no constraints on the sum of nn over all test cases.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤10001 \le t \le 1000)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \le n \le 100)—— 表示特殊点的数量。

接下来的 nn 行中,每行包含两个整数 xix_i、yiy_i(−100≤xi,yi≤100-100 \leq x_i, y_i \leq 100),表示特殊点 (xi,yi)(x_i, y_i)。

注意:对所有测试用例而言,nn 的总和没有额外限制。

输出格式

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).

对于每个测试用例,如果你能在不损坏控制器的情况下到达所有特殊点,则输出 "YES"(不带引号);否则输出 "NO"(不带引号)。

你可以以任意大小写形式输出每个字母(例如 "YES"、"Yes"、"yes"、"yEs" 均被视为肯定回答)。

输入输出样例

  • 输入#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)(0, 0);
  • you visit the special point (x2,y2)=(0,0)(x_2, y_2) = (0, 0);
  • you press R\texttt{R}, and you move from (0,0)(0, 0) to (1,0)(1, 0);
  • you press D\texttt{D}, and you move from (1,0)(1, 0) to (1,−1)(1, -1);
  • you visit the special point (x1,y1)=(1,−1)(x_1, y_1) = (1, -1);
  • you visit the special point (x3,y3)=(1,−1)(x_3, y_3) = (1, -1).

Therefore, you can visit all the special points using only the buttons R\texttt{R}, D\texttt{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\texttt{U}, D\texttt{D}, L\texttt{L}.

In the third test case, you can show that you must press all the buttons (U\texttt{U}, R\texttt{R}, D\texttt{D}, L\texttt{L}) to visit all the points, so the controller would break.

在第一个测试用例中,你可以按如下方式移动:

  • 你从 (0,0)(0, 0) 出发;
  • 你访问特殊点 (x2,y2)=(0,0)(x_2, y_2) = (0, 0);
  • 你按下 R\texttt{R},从 (0,0)(0, 0) 移动到 (1,0)(1, 0);
  • 你按下 D\texttt{D},从 (1,0)(1, 0) 移动到 (1,−1)(1, -1);
  • 你访问特殊点 (x1,y1)=(1,−1)(x_1, y_1) = (1, -1);
  • 你访问特殊点 (x3,y3)=(1,−1)(x_3, y_3) = (1, -1)。

因此,你仅使用按钮 R\texttt{R} 和 D\texttt{D} 就能访问所有特殊点,控制器不会损坏。

注意:特殊点可能重合。

在第二个测试用例中,你可以证明:仅使用按钮 U\texttt{U}、D\texttt{D}、L\texttt{L} 就能访问所有特殊点。

在第三个测试用例中,你可以证明:必须按下全部四个按钮(U\texttt{U}、R\texttt{R}、D\texttt{D}、L\texttt{L})才能访问所有点,因此控制器会损坏。

输入解题思路,AI测评打分。不知道怎么写?

首页