QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 256 MB 満点: 100

#11906. 非常纽约

統計

2211 年,火星上的城市 Very New York 的街道构成了一个完美的网格。城市中的每个交叉路口都可以用一对整数 $(x, y)$ 来表示。两个交叉路口 $(x_1, y_1)$ 和 $(x_2, y_2)$ 之间的距离等于 $|x_1 - x_2| + |y_1 - y_2|$。

一位投资者有兴趣在城里建一家酒店。由于酒店老板喜欢用“半英里内有 150 家餐厅”这样的短语来宣传酒店,投资者想要了解每个潜在位置在特定距离内有多少家餐厅。

输入格式

第一行包含一个整数 $R$,表示城市中餐厅的数量 ($0 \le R \le 100\,000$)。接下来的 $R$ 行,每行描述一家餐厅的坐标,包含两个整数 $x$ 和 $y$ ($1 \le x, y \le 1\,000\,000$)。

第 $R+2$ 行包含一个整数 $Q$,表示查询的数量 ($1 \le Q \le 100\,000$)。接下来的 $Q$ 行,每行包含一个查询。每个查询由三个整数 $x, y, d$ 组成 ($1 \le x, y, d \le 1\,000\,000$)。

输出格式

输出应包含 $Q$ 行,每行一个整数。第 $i$ 行应包含第 $i$ 个查询 $(x, y, d)$ 的答案:距离 $(x, y)$ 不超过 $d$ 的餐厅数量。

样例

样例输入 1

3
2 2
3 1
4 1
2
3 2 1
4 2 1

样例输出 1

2
1

样例输入 2

5
3 2
3 6
4 6
2 4
4 6
2
4 4 2
3 4 3

样例输出 2

3
5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.