#abc233h. Ex - Manhattan Christmas Tree
Ex - Manhattan Christmas Tree
Score : points
问题描述
在二维平面上有 棵圣诞树。第 棵树位于坐标 。
接下来回答 个查询。
查询 : 点 与其第 近的圣诞树之间的曼哈顿距离是多少?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are Christmas trees in the two-dimensional plane. The -th tree is at coordinates .
Answer the following queries.
Query : What is the distance between and the -th nearest Christmas tree to that point, measured in Manhattan distance?
Constraints
- if .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the answer to Query .
Sample Input 1
4
3 3
4 6
7 4
2 5
6
3 5 1
3 5 2
3 5 3
3 5 4
100 200 3
300 200 1
Sample Output 1
1
2
2
5
293
489
The distances from to the -st, -nd, -rd, -th trees to that point are , , , , respectively.
Thus, the answers to the first four queries are , , , , respectively.
update @ 2024/3/10 10:09:37