There are 2 circles, and their centers are fixed and will be entered as input. Then there will be n points whose x and y coordinates are given as input.
Finally, there will be q queries. For each request, the radius of two circles will be set (let them be r1 and r2). Print the total number of points inside the first circle or second circle for each query. A point lies inside a circle if the distance from the point to the center is less than or equal to the radius of the circle.
Limitations: n, q <= 10 ^ 6 r1, r2 <= 10 7 and for each coordinate | x | and | y | <= 10 ^ 6
I am looking for preprocessing O (nlogn) or O (nlog ^ 2n), and then the O (logn) algorithm for each request. The O (n) solution for the request is too slow. Any ideas how to hack this?
source
share