CF1030B.Vasya and Cornfield

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Vasya owns a cornfield which can be defined with two integers nn and dd. The cornfield can be represented as rectangle with vertices having Cartesian coordinates (0,d),(d,0),(n,n−d)(0, d), (d, 0), (n, n - d) and (n−d,n)(n - d, n).

An example of a cornfield with n=7n = 7 and d=2d = 2.

Vasya also knows that there are mm grasshoppers near the field (maybe even inside it). The ii-th grasshopper is at the point (xi,yi)(x_i, y_i). Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.

Help Vasya! For each grasshopper determine if it is inside the field (including the border).

瓦西娅拥有一片玉米田,该玉米田可用两个整数 nn 和 dd 来定义。这片玉米田可表示为一个四边形(矩形),其四个顶点的笛卡尔坐标分别为 (0,d)(0, d)、(d,0)(d, 0)、(n,n−d)(n, n - d) 和 (n−d,n)(n - d, n)。

一个 n=7n = 7、d=2d = 2 的玉米田示例。

瓦西娅还知道田地附近(甚至可能在田地内部)有 mm 只蚱蜢。第 ii 只蚱蜢位于点 (xi,yi)(x_i, y_i)。瓦西娅不喜欢蚱蜢吃他的玉米,因此他希望对每只蚱蜢判断其位置是否位于玉米田内部(含边界)或外部。

请帮助瓦西娅!对每只蚱蜢判断其是否位于田地内部(含边界)。

输入格式

The first line contains two integers nn and dd (1≤d<n≤1001 \le d \lt n \le 100).

The second line contains a single integer mm (1≤m≤1001 \le m \le 100) — the number of grasshoppers.

The ii-th of the next mm lines contains two integers xix_i and yiy_i (0≤xi,yi≤n0 \le x_i, y_i \le n) — position of the ii-th grasshopper.

第一行包含两个整数 nn 和 dd(1≤d<n≤1001 \le d \lt n \le 100)。

第二行包含一个整数 mm(1≤m≤1001 \le m \le 100)—— 蚱蜢的数量。

接下来的 mm 行中,第 ii 行包含两个整数 xix_i 和 yiy_i(0≤xi,yi≤n0 \le x_i, y_i \le n)—— 第 ii 只蚱蜢的位置。

输出格式

Print mm lines. The ii-th line should contain "YES" if the position of the ii-th grasshopper lies inside or on the border of the cornfield. Otherwise the ii-th line should contain "NO".

You can print each letter in any case (upper or lower).

输出 mm 行。第 ii 行应包含 "YES",当且仅当第 ii 只蚱蜢的位置位于玉米田内部或边界上;否则第 ii 行应包含 "NO"。

每个字母可以以任意大小写形式输出(大写或小写)。

输入输出样例

  • 输入#1

    7 2
    4
    2 4
    4 1
    6 3
    4 5

    输出#1

    YES
    NO
    NO
    YES
  • 输入#2

    8 7
    4
    4 4
    2 8
    8 1
    6 1

    输出#2

    YES
    NO
    YES
    YES

说明/提示

The cornfield from the first example is pictured above. Grasshoppers with indices 11 (coordinates (2,4)(2, 4)) and 44 (coordinates (4,5)(4, 5)) are inside the cornfield.

The cornfield from the second example is pictured below. Grasshoppers with indices 11 (coordinates (4,4)(4, 4)), 33 (coordinates (8,1)(8, 1)) and 44 (coordinates (6,1)(6, 1)) are inside the cornfield.

第一个样例的玉米田如上图所示。编号为 11(坐标 (2,4)(2, 4))和 44(坐标 (4,5)(4, 5))的蚱蜢位于玉米田内部。

第二个样例的玉米田如下图所示。编号为 11(坐标 (4,4)(4, 4))、33(坐标 (8,1)(8, 1))和 44(坐标 (6,1)(6, 1))的蚱蜢位于玉米田内部。

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

首页