#P17186. [ICPC 2017 Hong Kong R] Nearby Bicycles

[ICPC 2017 Hong Kong R] Nearby Bicycles

Problem 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 mm bicycles and nn customers, where each bicycle is located at coordinate (cj,dj)(c_j, d_j) for j=1,2,,mj = 1, 2, \dots, m, and each user ii is located at coordinate (ai,bi)(a_i, b_i) for i=1,2,,ni = 1, 2, \dots, n. The distance between two coordinates (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is measured by (x1x2)2+(y1y2)2\sqrt{(x_1-x_2)^2 + (y_1-y_2)^2}. For each user i=1,2,,ni = 1, 2, \dots, n, you are given a threshold sis_i, your task is to return the total number of bicycles that are within a distance of sis_i from user ii.

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, mm and nn (0<m,n10000 < m, n \le 1000). The second line contains the coordinates, (c1,d1),(c2,d2),,(cm,dm)(c_1, d_1), (c_2, d_2), \dots, (c_m, d_m), of bicycles 1,2,,m1, 2, \dots, m, respectively, which are separated by a space. The third line contains the coordinates, (a1,b1),(a2,b2),,(an,bn)(a_1, b_1), (a_2, b_2), \dots, (a_n, b_n), of users 1,2,,n1, 2, \dots, n, respectively, which are separated by a space. The fourth line contains the thresholds, s1,s2,,sns_1, s_2, \dots, s_n, of the nn users. The last test case is followed by a line of two 00s. All the coordinate numbers in the input are in the range [100000,100000][-100000, 100000].

Output Format

The output for each test case contains a line of nn integers, k1,k2,,knk_1, k_2, \dots, k_n, where each kik_i represents the total number of bicycles that are within a distance of sis_i from user ii, for i=1,2,,ni = 1, 2, \dots, n.

4 2
(0,0) (0,1) (1,0) (1,1)
(0,0) (1,1)
1 1
0 0
3 3