← 返回 waymo 的题目列表Maximum Area Axis-Aligned Rectangle From Points
类型:online_judge
Given a set of points points on a 2D plane, where each point has integer coordinates (x, y).
Find the maximum area of an axis-aligned rectangle whose four vertices all appear in points. If no such rectangle exists, return 0.
Rules:
All four corners must be present in points.
Area is (x2 - x1) * (y2 - y1) with x1 != x2 and y1 != y2.
Input (stdin)
Line 1: integer n, number of points.
Next n lines: two integers x y.
Output (stdout)
One integer: the maximum rectangle area, or 0 if none exists.
Constraints (practice scale)
1 <= n <= 2 * 10^4
-10^9 <= x, y <= 10^9
Example input:
6
1 1
1 3
3 1
3 3
2 2
3 2
Example output:
4
Example
Input
6
1 1
1 3
3 1
3 3
2 2
3 2
Output
4