Hi, I'm stuck in such a problem who ask's for the given set G of points in a plane, for each point i, how many points s are less than an integer D close to point i.
My fist and naive approach was an O(N^2) solution looking for the distance from all points to points, which didn't got TLE.
What is the better approach ?
Please, give link to problem.
The statement is in portuguese, here it is Link
It turns out that the problem uses Manhattan distance. Take a look at the Pairs problem from http://ioi2007.hsin.hr/tasks/solutions.pdf for the idea of a solution.
thanks, it's exactly what is needed :D
You can use convex hull which garanted O(NlogN) time
what does it give you?
http://rain.ifmo.ru/cat/view.php/theory/math/geometry-2005
Read the problem more carefully. It seems, you misunderstood it.
I'm not asking you for a link. There are a lot of links in the internet. I just asked : "What does it give you?" Please, explain.
Thanks.