[BOJ 9611] Vicinity

View as PDF

Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 128M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

This is one of the most basic geometry proximity problems. We are given n points in the plane and we should determine which points are in the vicinity of a particular point. </p>

Let the set of points P = {p1, p2 , …, pn} , where pi has coordinates (xi, yi). We use d(pi,pj) to denote the distance between the two points. A point pj is in the vicinity of point pi if d(pi,pj) ≤ dv .We may call dv the vicinity distance. Given a set of points P, point pi and dv, your task is to write a program to calculate the number of points which are in the vicinity of point pi

입력 형식

The first line contains an integer n (2≤ n ≤ 1000) which determines the number of points. The following n lines contain two integers which correspond to the coordinates (xi,yi) of each point (-10≤ xi, yi ≤ 106). Then, the following line includes t (1≤ t ≤ 50) indicating the number of test cases, followed by t lines and each line contains 2 positive integers i (1≤ i ≤ n) and dv (1 ≤ dv ≤ 100) which indicate the point pi and its vicinity distance, respectively. 

출력 형식

For each test case, print out in a line the number of points in the vicinity of the corresponding point. 

예제 입력

5
0 0
0 1
1 1
3 -3
2 2
3
1 1
5 3
4 1

예제 출력

1
3
0

Comments

There are no comments at the moment.