#P11578. Minimum Bounding Frame for Mahima's Masterpiece
Minimum Bounding Frame for Mahima's Masterpiece
Minimum Bounding Frame for Mahima's Masterpiece
Mahima is exploring a new artistic style by creating paintings with scattered drops of paint on her canvas. When she believes she has created a masterpiece, she uses a 3D printer to generate a rectangular frame that will protect the artwork.
Your task is to help Mahima by finding the coordinates of the smallest possible rectangular frame such that every drop of paint is strictly inside the frame. Note that points on the boundary are not considered to be inside the frame.
Formally, suppose there are \( n \) paint drops with coordinates \( (x_i, y_i) \) for \( 1 \le i \le n \). Define
[ x_{min} = \min_{1 \le i \le n} x_i, \quad x_{max} = \max_{1 \le i \le n} x_i, ]
[ y_{min} = \min_{1 \le i \le n} y_i, \quad y_{max} = \max_{1 \le i \le n} y_i. ]
Since a drop exactly on the boundary is not inside the frame, the frame boundaries must satisfy:
[ \text{left} < x_{min}, \quad \text{right} > x_{max}, ]
[ \text{bottom} < y_{min}, \quad \text{top} > y_{max}. ]
The smallest integer boundaries that achieve this are:
[ \text{left} = x_{min} - 1, \quad \text{bottom} = y_{min} - 1, \quad \text{right} = x_{max} + 1, \quad \text{top} = y_{max} + 1. ]
</p>inputFormat
The first line contains an integer \( n \) representing the number of paint drops. Each of the following \( n \) lines contains two space-separated integers \( x_i \) and \( y_i \), the coordinates of a paint drop.
outputFormat
Output four space-separated integers denoting the coordinates of the frame: left, bottom, right, and top.
sample
1
0 0
-1 -1 1 1