A Manhattan Distance Problem

Revision en1, by 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?

Tags manhattan, distance, problem, queries

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English offson 2016-05-27 05:19:07 662 Initial revision (published)