eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Vicinity

Vicinity

Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB

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.

Let the set of points P = {p_1, p_2 , …, p_n}, where p_i has coordinates (x_i, y_i). We use d(p_i, p_j) to denote the distance between the two points. A point p_j is in the vicinity of point p_i if d(p_i, p_j)d_v. We may call d_v the vicinity distance. Given a set of points P, point p_i and d_v, your task is to write a program to calculate the number of points which are in the vicinity of point p_i.

Вхідні дані

The first line contains an integer n (2n1000) which determines the number of points. The following n lines contain two integers which correspond to the coordinates (x_i, y_i) of each point (-10^6x_i, y_i10^6). Then, the following line includes t (1t50) indicating the number of test cases, followed by t lines and each line contains 2 positive integers i (1in) and d_v (1d_v100) which indicate the point p_i 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.

Приклад

Вхідні дані #1
5
0 0
0 1
1 1
3 -3
2 2
3
1 1
5 3
4 1
Вихідні дані #1
1
3
0
Джерело ACM-ICPC Asia Phuket Regional Programming Contest 2013, Practice Session, 21 November 2013