Maximum Number of Squares
Time limit2sMemory limit128 MB
Given N points on a plane, place them to maximize the number of axis-aligned squares whose four vertices are chosen points.
- Level
Hard8 of 10
- Topics
- Math, Combinatorics, Geometry, Brute force
- Solved
- No attempts yet
Problem
Place N distinct points on a two-dimensional plane. A square is counted when its four vertices are among the chosen points and every side is parallel to one of the coordinate axes.
The same square is counted only once; squares with different positions or side lengths are distinct.
Given N, find the maximum possible number of such squares.
Input
The first line contains an integer N. It satisfies 0 <= N <= 1,000,000.
Output
Print the maximum possible number of squares on the first line.