#P1369. Maximum Boundary Points Rectangle

    ID: 14656 Type: Default 1000ms 256MiB

Maximum Boundary Points Rectangle

Maximum Boundary Points Rectangle

Given n points on a plane, find a rectangle with edges parallel to the coordinate axes such that the number of points on its boundary is maximized.

A point \( (x, y) \) is considered to be on the boundary of a rectangle defined by \( x_{min}, x_{max}, y_{min}, y_{max} \) if it satisfies at least one of the following conditions:

  • \( x = x_{min} \) or \( x = x_{max} \) and \( y_{min} \le y \le y_{max} \), or
  • \( y = y_{min} \) or \( y = y_{max} \) and \( x_{min} \le x \le x_{max} \).

The rectangle must have a positive area, i.e. \( x_{min} < x_{max} \) and \( y_{min} < y_{max} \). If multiple solutions exist, output any one of them.

inputFormat

The first line contains an integer \( n \) (e.g., \(1 \le n \le 100\)) representing the number of points. Each of the following \( n \) lines contains two space-separated integers \( x \) and \( y \) representing the coordinates of a point.

outputFormat

Output four integers: \( x_{min} \), \( x_{max} \), \( y_{min} \), and \( y_{max} \) representing the boundaries of the rectangle that maximizes the number of points on its boundary.

sample

4
0 0
0 1
1 0
1 1
0 1 0 1