#C1128. Smallest Enclosing Rectangle
Smallest Enclosing Rectangle
Smallest Enclosing Rectangle
Given a set of points in a 2D plane, determine the smallest axis-aligned rectangle that encloses all the points.
If there are no points, output None
.
Formally, for a set of points \(\{(x_i,y_i)\}\), the rectangle is defined by its lower-left corner \( (\min_i x_i,\min_i y_i) \) and its upper-right corner \( (\max_i x_i,\max_i y_i) \).
inputFormat
The first line of input contains an integer \( n \) denoting the number of points. Each of the following \( n \) lines contains two space-separated integers representing the coordinates \( x \) and \( y \) of a point.
outputFormat
If \( n > 0 \), print four space-separated integers: \(\min(x)\), \(\min(y)\), \(\max(x)\), and \(\max(y)\). If \( n == 0 \), print None
.
5
1 1
2 3
4 4
3 -1
0 2
0 -1 4 4