Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

offson's blog

By offson, history, 8 years ago, In English

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?

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it