A Manhattan Distance Problem

Правка en1, от offson, 2016-05-27 05:19:07

You are given N points with integer coordinates (Xi, Yi) and Q queries. In each query, you are given one of the points given in the input, let's call it P. For each query, you need to answer which point given in the input is the closest to P, considering that the distance between two points is the Manhattan Distance. If there is more than one point with the same distance, the one with lower X should be chosen. If the tie persists, the one with lower Y should be chosen.

1 <= N <= 105

1 <= Q <= 105

1 <= Xi, Yi <= 103

Any ideas?

Теги manhattan, distance, problem, queries

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский offson 2016-05-27 05:19:07 662 Initial revision (published)