QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 64 MB Puntuación total: 20

#23764. 最古老的遺跡

Estadísticas

很久以前,那裡曾有一處聚落,居住著許多人。人們建造了形狀和大小各異的建築物。然而,那些建築物早已消失,只有文獻和遺跡中發現的柱子成為得知建築物位置的線索。

文獻中有關於神殿的記載。從上方俯視,神殿呈精確的正方形,且其四角各有柱子。神殿朝向哪個方向已不得而知,而且也不知道其邊上或內部是否曾有柱子。考古學家們認為,在遺跡中發現的柱子所構成的正方形中,面積最大的那一個一定就是神殿。

給定各根柱子位置的座標,請編寫一個程式,在由 $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.