Problem statement Positive integer N and in the xy-plane N points in the xy plane S and…
- User
Problem statement Positive integer N and in the xy-plane N points in the xy plane S and a positive integer M and and M points in the xy-plane. T consisting of M points in the xy-plane. T is given.
The elements of S s=(x,y) and T and an element of T t=(z,w) and the distance d(s,t), ℓ 1 distance (Manhattan distance)
∣x-z∣+∣y-w∣
is defined as ∣x-z∣+∣y-w∣. Furthermore S and T is the distance D(S,T), s and t, respectively. S and T, respectively. The minimum value of d(s,t)
(s,t) ∈ S × T min
d(s,t)
is determined as Find D(S,T).
Input Let the elements of S be n, each positive integer less than or equal to n, and s n
=(x n
,y n
) and place the Let the elements of T be M and number the elements of T by each positive integer m, and t m
=(z m
,w m
).
At this point, the input is given in the following form from the standard input 2+N+M lines are given:
The first line is given as N is given on the first line. For each positive integer less than or equal to N For n, For each positive integer n less than or equal to N x n
,y n
are given separated by single-byte spaces. On line 2+N M is given. For each positive integer less than or equal to M for each positive integer less than or equal to m, For each positive integer m less than or equal to z m
,w m
are given separated by single-byte blanks. N x 1
y 1
⋮ ⋮ y x N
y N
M z 1
w 1
z M
w M
Constraints The input satisfies the following constraints
N must be 1≤N≤2×10 5 is an integer satisfying Any positive integer less than or equal to N For n, x n
is an integer of the form 0≤x n
<10 3 is an integer satisfying y n
is an integer satisfying 0≤y n
<10 3 is an integer satisfying Any positive integer less than or equal to n n 0
,n 1
whereas n 0
=n 1
Then s n 0
=s n 1
where M is the number of the M is a function of 1≤M<2×10 5 is an integer satisfying 1≤M<2×10 5 Any positive integer less than or equal to M For m, z m
is a positive integer less than or equal to 0≤z m
<10 3 is an integer satisfying w m
is an integer such that 0≤w m
<10 3 is an integer satisfying Any positive integer less than or equal to m m 0
,m 1
whereas m 0
=m 1
Then t m 0
=t m 1
and is Output. D(S,T). Output to one line.
- Assistant