QOJ.ac

QOJ

时间限制: 12 s 内存限制: 2048 MB 总分: 100

#10467. 咖啡中心

统计

这只是昙花一现,还是会持续下去?你并不确定,但家乡不断增加的咖啡店数量确实成了一大亮点。显然,人们对咖啡已经上瘾,以至于靠近许多咖啡店的公寓租金更高。

当地一家房地产公司注意到了这一点。他们有兴趣根据咖啡店的密集程度来确定城市中最有价值的地段。他们给了你一张标有咖啡店位置的城市地图。假设普通人只愿意为早晨的咖啡步行固定的街区数,你必须找到一个位置,从该位置出发可以到达最多的咖啡店。如你所知,你的家乡是建立在方形网格布局上的,街区沿南北和东西轴线排列。由于你必须沿街道行走,因此交叉路口 $(a, b)$ 和 $(c, d)$ 之间的距离为 $|a - c| + |b - d|$。

输入格式

输入包含多个测试用例。每个测试用例描述一个城市。每个测试用例的第一行包含四个整数 $dx, dy, n$ 和 $q$。这些分别是城市网格的尺寸 $dx \times dy$ ($1 \le dx, dy \le 1000$)、咖啡店数量 $n$ ($0 \le n \le 5 \cdot 10^5$) 以及查询数量 $q$ ($1 \le q \le 20$)。接下来的 $n$ 行,每行包含两个整数 $x_i$ 和 $y_i$ ($1 \le x_i \le dx, 1 \le y_i \le dy$);这些指定了第 $i$ 家咖啡店的位置。每个交叉路口最多只有一家咖啡店。接下来的 $q$ 行,每行包含一个整数 $m$ ($0 \le m \le 10^6$),即一个人愿意为一杯咖啡步行的最大距离。

最后一个测试用例之后是一行包含四个零的输入。

输出格式

对于输入中的每个测试用例,显示其用例编号。然后为测试用例中的每个查询显示一行。每一行显示在给定的查询距离 $m$ 下可到达的最大咖啡店数量,以及最优位置。例如,样例输出显示在最优位置 $(3, 4)$ 的查询距离 $1$ 内有 $3$ 家咖啡店,在最优位置 $(2, 2)$ 的查询距离 $2$ 内有 $4$ 家咖啡店,在最优位置 $(3, 1)$ 的查询距离 $4$ 内有 $5$ 家咖啡店。如果有多个最优位置,请选择最靠南的位置(最小的正整数 $y$ 坐标)。如果仍然平局,请选择最靠西的位置(最小的正整数 $x$ 坐标)。

请遵循样例输出的格式。

样例

输入 1

4 4 5 3
1 1
1 2
3 3
4 4
2 4
1
2
4
0 0 0 0

输出 1

Case 1:
3 (3,4)
4 (2,2)
5 (3,1)

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.