CF2202A.Parkour Design

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Today, Alex wants to build a parkour course for Steve to train his parkour skills on. A parkour course is a sequence p0→p1→…→pkp_0 \to p_1 \to \ldots \to p_k of integer coordinates on the plane. Here, a contiguous pair of coordinates is called a move, denoted as pi−1→pip_{i-1} \to p_i.

Alex knows that Steve can only perform the following types of moves:

  • (xi,yi)→(xi+2,yi+1)(x_i,y_i) \to (x_i+2,y_i+1);
  • (xi,yi)→(xi+3,yi)(x_i,y_i) \to (x_i+3,y_i);
  • (xi,yi)→(xi+4,yi−1)(x_i,y_i) \to (x_i+4,y_i-1).

Note that Steve will not perform any other type of moves. For example, Steve can perform (0,0)→(2,1)(0,0) \to (2,1) and (2,1)→(5,1)(2,1) \to (5,1), but will never perform moves such as (2,1)→(3,2)(2,1) \to (3,2), (3,0)→(5,−1)(3,0) \to (5,-1), or (4,−1)→(6,−1)(4,-1) \to (6,-1) (even though they may look very easy).

You are given an integer coordinate (x,y)(x,y) on the plane.

Please determine if it is possible to make a parkour course q0,q1,…,qkq_0,q_1,\ldots,q_k that satisfies the following conditions:

  • q0=(0,0)q_0=(0,0);
  • qk=(x,y)q_k=(x,y);
  • The parkour course only consists of moves that Steve can perform.

今天,Alex 想为 Steve 设计一个跑酷训练课程。一个跑酷课程是一组平面上的整数坐标序列 p0→p1→…→pkp_0 \to p_1 \to \ldots \to p_k。其中,相邻两个坐标构成一次“移动”,记作 pi−1→pip_{i-1} \to p_i。

Alex 知道 Steve 只能执行以下三种类型的移动:

  • (xi,yi)→(xi+2,yi+1)(x_i,y_i) \to (x_i+2,y_i+1);
  • (xi,yi)→(xi+3,yi)(x_i,y_i) \to (x_i+3,y_i);
  • (xi,yi)→(xi+4,yi−1)(x_i,y_i) \to (x_i+4,y_i-1)。

注意:Steve 不会执行任何其他类型的移动。例如,Steve 可以执行 (0,0)→(2,1)(0,0) \to (2,1) 和 (2,1)→(5,1)(2,1) \to (5,1),但绝不会执行如 (2,1)→(3,2)(2,1) \to (3,2)、(3,0)→(5,−1)(3,0) \to (5,-1) 或 (4,−1)→(6,−1)(4,-1) \to (6,-1) 这样的移动(即使它们看起来非常简单)。

你将获得平面上的一个整数坐标 (x,y)(x,y)。

请判断是否存在一个跑酷课程 q0,q1,…,qkq_0,q_1,\ldots,q_k,满足以下条件:

  • q0=(0,0)q_0=(0,0);
  • qk=(x,y)q_k=(x,y);
  • 该跑酷课程仅由 Steve 能够执行的移动组成。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1031 \le t \le 10^3). The description of the test cases follows.

The only line of each test case contains two integers xx and yy (1≤x≤1091 \le x \le 10^9, −108≤y≤108-10^8 \le y \le 10^8).

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

每个测试用例仅有一行,包含两个整数 xx 和 yy(1≤x≤1091 \le x \le 10^9,−108≤y≤108-10^8 \le y \le 10^8)。

输出格式

If it is possible to make a parkour course that satisfies the conditions, output "YES" on a separate line.

If it is impossible to make a parkour course that satisfies the conditions, output "NO" on a separate line.

You can output the answer in any case. For example, the strings "yEs", "yes", and "Yes" will also be recognized as positive responses.

如果可以构造出满足条件的跑酷课程,则在单独一行输出“YES”。

如果无法构造出满足条件的跑酷课程,则在单独一行输出“NO”。

你可以以任意大小写形式输出答案。例如,字符串 “yEs”、“yes” 和 “Yes” 也会被识别为肯定回答。

输入输出样例

  • 输入#1

    11
    2 1
    3 0
    4 -1
    4 1
    14 1
    1 -4
    3 -1
    2 10
    24 -1
    24 -3
    8 4

    输出#1

    YES
    YES
    YES
    NO
    YES
    NO
    NO
    NO
    NO
    YES
    YES

说明/提示

For the fifth test case, the parkour course must start from (0,0)(0,0) and end on (14,1)(14,1).

This can be achieved by the following parkour course.

(0,0)to(4,−1)to(7,−1)to(9,0)to(12,0)to(14,1)(0,0) \\to (4,-1) \\to (7,-1) \\to (9,0) \\to (12,0) \\to (14,1)

Note that the following parkour course does not satisfy the third condition stated above due to the moves highlighted in red.

(0,0)tocolorred(4,−1)to(6,−1)to(8,0)tocolorred(11,0)to(14,1)(0,0) \\to \\color{red}{(4,-1) \\to (6,-1)} \\to (8,0) \\to \\color{red}{(11,0) \\to (14,1)}

对于第五个测试用例,跑酷路线必须从 (0,0)(0,0) 开始,并在 (14,1)(14,1) 结束。

以下跑酷路线可满足该要求:

(0,0)to(4,−1)to(7,−1)to(9,0)to(12,0)to(14,1)(0,0) \\to (4,-1) \\to (7,-1) \\to (9,0) \\to (12,0) \\to (14,1)

注意:以下跑酷路线因红色高亮标出的移动步骤,不满足上述第三条条件:

(0,0)tocolorred(4,−1)to(6,−1)to(8,0)tocolorred(11,0)to(14,1)(0,0) \\to \\color{red}{(4,-1) \\to (6,-1)} \\to (8,0) \\to \\color{red}{(11,0) \\to (14,1)}

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

首页