P17186 [ICPC 2017 Hong Kong R] Nearby Bicycles

Description

With fast developments of information and communication technology, many cities today have established bicycle sharing systems. The key component of the system is to provide information on nearby bicycles to potential users. Consider $m$ bicycles and $n$ customers, where each bicycle is located at coordinate $(c_j, d_j)$ for $j = 1, 2, \dots, m$, and each user $i$ is located at coordinate $(a_i, b_i)$ for $i = 1, 2, \dots, n$. The distance between two coordinates $(x_1, y_1)$ and $(x_2, y_2)$ is measured by $\sqrt{(x_1-x_2)^2 + (y_1-y_2)^2}$. For each user $i = 1, 2, \dots, n$, you are given a threshold $s_i$, your task is to return the total number of bicycles that are within a distance of $s_i$ from user $i$.

Input Format

The test data may contain many test cases. Each test case contains four lines. The first line of each case contains two integers, $m$ and $n$ ($0 < m, n \le 1000$). The second line contains the coordinates, $(c_1, d_1), (c_2, d_2), \dots, (c_m, d_m)$, of bicycles $1, 2, \dots, m$, respectively, which are separated by a space. The third line contains the coordinates, $(a_1, b_1), (a_2, b_2), \dots, (a_n, b_n)$, of users $1, 2, \dots, n$, respectively, which are separated by a space. The fourth line contains the thresholds, $s_1, s_2, \dots, s_n$, of the $n$ users. The last test case is followed by a line of two $0$s. All the coordinate numbers in the input are in the range $[-100000, 100000]$.

Output Format

The output for each test case contains a line of $n$ integers, $k_1, k_2, \dots, k_n$, where each $k_i$ represents the total number of bicycles that are within a distance of $s_i$ from user $i$, for $i = 1, 2, \dots, n$.