QOJ.ac

QOJ

Süre Sınırı: 3 s Bellek Sınırı: 64 MB Toplam puan: 20

#23764. 最古老的遗迹

İstatistikler

很久以前,那里曾有一处聚落,居住着许多人。人们建造了形状和大小各异的建筑物。然而,那些建筑物早已消失,只有文献和遗迹中发现的柱子成为得知建筑物位置的线索。

文献中有关于神殿的记载。从上方俯视,神殿呈精确的正方形,且其四角各有柱子。神殿朝向哪个方向已不得而知,而且也不知道其边上或内部是否曾有柱子。考古学家们认为,在遗迹中发现的柱子所构成的正方形中,面积最大的那一个一定就是神殿。

给定各根柱子位置的坐标,请编写一个程序,在由 $4$ 根柱子所能构成的正方形中找出面积最大的一个,并输出其面积。注意,正方形的边不一定与坐标轴平行。

例子

在下图所示的例子中,共有 $10$ 根柱子,位于坐标 $(4, 2), (5, 2), (5, 3), (4, 3)$ 的 $4$ 根柱子与位于坐标 $(1, 1), (4, 0), (5, 3), (2, 4)$ 的 $4$ 根柱子各构成一个正方形。面积最大的正方形是后者,其面积为 $10$。

输入

第 $1$ 行写有在遗迹中发现的柱子根数 $n$。

从第 $2$ 行到第 $n + 1$ 行的 $n$ 行中,每行各写有一根柱子的 $x$ 坐标与 $y$ 坐标,以空格分隔。

同 $1$ 根柱子不会出现 $2$ 次或以上。

$n$ 是满足 $1 \le n \le 3000$ 的整数,且柱子的 $x$ 坐标与 $y$ 坐标均为大于等于 $0$ 且小于等于 $5000$ 的整数。

在评测数据中,占总分 $30\%$ 的数据满足 $1 \le n \le 100$,占总分 $60\%$ 的数据满足 $1 \le n \le 500$。

输出

输出 $1$ 个整数。如果存在由 $4$ 根柱子构成的正方形,则输出此类正方形中面积最大者的面积;如果不存在这样的正方形,则输出 $0$。

样例输入与输出

样例输入 1

与例子对应的输入与输出如下。

10
9 4
4 3
1 1
4 2
2 4
5 8
4 0
5 3
0 5
5 2

样例输出 1

10

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.