Vicinity
InterviewTime limit1sMemory limit128 MB
For each query, count how many of the n points lie within distance d_v of the chosen base point, excluding the base point itself.
- Level
Easy2 of 10
- Topics
- Brute force, Geometry
- Solved
- No attempts yet
Problem
You are given several points in the plane. Pick one of them as the base point and count how many points lie close to it.
Let the set of points be , where has coordinates . Write for the Euclidean distance between two points. Point is in the vicinity of point when , and is called the vicinity distance.
Given the set , a base point and a vicinity distance , write a program that computes how many points are in the vicinity of . The base point itself is not counted.
Input
The first line contains the number of points (). Each of the next lines contains the integer coordinates and of one point ().
The next line contains the number of queries (). Each of the following lines contains two positive integers and (, ), meaning the base point and its vicinity distance .
Output
For each query, print on its own line how many points are in the vicinity of the base point.