QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 64 MB 満点: 20

#23764. 最古老嘅遺蹟

統計

好耐以前,嗰度曾經有一個聚落,住咗好多人。人們起咗形狀同大細各異嘅建築物。不過,嗰啲建築物已經消失晒,淨係得文獻同埋遺蹟入面搵到嘅柱,成為知道建築物位置嘅線索。

文獻入面有關於神殿嘅記載。由上面望落去,神殿係一個精確嘅正方形,而且佢嘅四個角都有柱。神殿面向邊個方向已經唔知,亦都唔知佢嘅邊上面或者內部有冇柱。考古學家認為,喺遺蹟入面搵到嘅柱所組成嘅正方形之中,面積最大嘅嗰一個一定就係神殿。

給定各條柱位置嘅坐標,請編寫一個程式,喺由 $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.