A12034 | Vasya and Cornfield
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya owns a cornfield which can be defined with two integers $n$ and $d$ . The cornfield can be represented as rectangle with vertices having Cartesian coordinates $(0, d), (d, 0), (n, n - d)$ and $(n - d, n)$ .
An example of a cornfield with $n = 7$ and $d = 2$ .Vasya also knows that there are $m$ grasshoppers near the field (maybe even inside it). The $i$ -th grasshopper is at the point $(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).
An example of a cornfield with $n = 7$ and $d = 2$ .Vasya also knows that there are $m$ grasshoppers near the field (maybe even inside it). The $i$ -th grasshopper is at the point $(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).
输入格式
The first line contains two integers $n$ and $d$ ( $1 \le d < n \le 100$ ).
The second line contains a single integer $m$ ( $1 \le m \le 100$ ) — the number of grasshoppers.
The $i$ -th of the next $m$ lines contains two integers $x_i$ and $y_i$ ( $0 \le x_i, y_i \le n$ ) — position of the $i$ -th grasshopper.
The second line contains a single integer $m$ ( $1 \le m \le 100$ ) — the number of grasshoppers.
The $i$ -th of the next $m$ lines contains two integers $x_i$ and $y_i$ ( $0 \le x_i, y_i \le n$ ) — position of the $i$ -th grasshopper.
输出格式
Print $m$ lines. The $i$ -th line should contain "YES" if the position of the $i$ -th grasshopper lies inside or on the border of the cornfield. Otherwise the $i$ -th line should contain "NO".
You can print each letter in any case (upper or lower).
You can print each letter in any case (upper or lower).
输入输出样例
输入 #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 $1$ (coordinates $(2, 4)$ ) and $4$ (coordinates $(4, 5)$ ) are inside the cornfield.
The cornfield from the second example is pictured below. Grasshoppers with indices $1$ (coordinates $(4, 4)$ ), $3$ (coordinates $(8, 1)$ ) and $4$ (coordinates $(6, 1)$ ) are inside the cornfield.

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

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted