#P8922. 『MdOI R5』Squares
『MdOI R5』Squares
Background
This problem is not a data structure problem. It is recommended to solve F first.
Problem Description
Given points on the plane, define a region on the plane as good if and only if it is a square with sides parallel to the coordinate axes and there is no given point strictly contained in it. Then there are queries. Each query gives a point . For each query, find the side length of the largest good region that strictly contains . If it can be infinitely large, output .
A point is strictly contained in a region if and only if is inside and not on its boundary.
To reduce tricky details, it is guaranteed that all the points have pairwise distinct -coordinates, and pairwise distinct -coordinates.
Input Format
The first line contains two positive integers .
The next lines each contain two integers , representing a given point .
The next lines each contain two integers , representing the point given in a query.
Output Format
Output lines. Each line contains one integer. The integer on the -th line is the answer to the -th query.
4 2
1 0
0 3
4 1
3 4
2 2
5 5
4
-1
Hint
For of the data, , .
: .
: .
: .
: .
: .
: no special constraints.
Sample Explanation 1
For the first query, the square with bottom-left corner and side length is the largest good region that strictly contains .
For the second query, the square with bottom-left corner and side length is the largest good region that strictly contains .
Translated by ChatGPT 5
