#P4169. [Violet] 天使玩偶/SJY摆棋子
[Violet] 天使玩偶/SJY摆棋子
Description
Seven years ago, Ayu received an angel doll. She buried it underground as a time capsule. But today, seven years later, Ayu has forgotten where she buried it, so she decides to look for it based only on some vague memories.
We treat the town where Ayu lives as a 2D Cartesian coordinate plane. From time to time, Ayu will recall that the doll might have been buried at some point ; or she will ask you: if she is at , how far is it to the nearest location where the angel doll might have been buried.
Because Ayu only moves along directions parallel to the coordinate axes, in this problem we define the distance between two points as $\operatorname{dist}(A, B) = |A_x - B_x| + |A_y - B_y|$. Here denotes the -coordinate of point , and similarly for the others.
Input Format
The first line contains two integers and . At the start, Ayu already knows points where the doll might be buried, and then she will perform operations.
The next lines each contain two non-negative integers , denoting the coordinates of the initial points.
Then the next lines each contain three non-negative integers .
- If , Ayu recalls another point where the doll might be buried.
- If , Ayu asks: if she is at , among the points recalled so far, how far is the nearest point to her.
Output Format
For each query with , output the result on a separate line.
2 3
1 1
2 3
2 1 2
1 3 3
2 4 2
1
2
Hint
Constraints: For of the testdata, it is guaranteed that and .
Translated by ChatGPT 5
京公网安备 11011102002149号