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.