#P6224. [BJWC2014] 数据
[BJWC2014] 数据
Description
To write his thesis, Alex often needs to organize a large amount of data. This time, Alex faces a serious challenge: he needs to implement a data structure to maintain a set of points.
Now there are points on a 2D plane.
Alex needs to support the following three operations:
-
Add a point to the set.
-
Given a point, query the minimum Manhattan distance from it to all points in the set.
-
Given a point, query the maximum Manhattan distance from it to all points in the set.
The Manhattan distance between two points is defined as the sum of the absolute difference of their -coordinates and the absolute difference of their -coordinates.
Such a difficult problem is of course beyond Alex, so he has to ask you for help again.
Input Format
The first line contains an integer , indicating the initial number of points in the set.
The next lines each contain two integers, representing the -coordinate and -coordinate of a point.
Line contains an integer , indicating the number of queries.
The next lines each contain three integers, representing the query type, the -coordinate, and the -coordinate. Type means adding a point, type means querying the minimum Manhattan distance to that point, and type means querying the maximum.
Output Format
Output several lines, in order, each being the answer to a query operation.
3
7 5
6 2
3 1
5
1 6 1
1 5 5
2 7 1
0 3 2
1 1 0
1
2
4
3
Hint
For the first of the testdata: .
For of the testdata: .
The coordinates of points are non-negative integers not exceeding .
Translated by ChatGPT 5
京公网安备 11011102002149号