Your task is to find out minimum distant cab for each customer.
The first line of the input contains an integer T denoting the number of test cases.
The description of T test cases follows. The first line of each test case contains two space-separated integers N and M, denoting the number of cabs and the number of customers.
The next N lines contain two space-separated integers x[i] and y[i], denoting the initial position of the ith cab.
Next line contains an integer M denoting number of customers. The next M lines contain four space seperated integers sx[i], sy[i], dx[i], dy[i], denoting the current location and the destination of the ith customer.
Output the nearest cab number for each customer.
-10^9<=x[i] , y[i] , sx[i] , sy[i] , dx[i] , dy[i]<=10^9
2 3 3 4
5 3 4 1
The distance of cab1 from customer1 = sqrt((1-2)^2 + (3-3)^2) = 1
The distance of cab2 from customer1 = sqrt(2)
The distance of cab3 from customer1 = sqrt(5)
So output for customer1 is 1
Now location of cab1 is (3,4)
The distance of cab1 from customer2 = sqrt((3-5)^2 + (4-3)^2) = sqrt(5)
The distance of cab2 from customer2 = sqrt(5)
The distance of cab3 from customer2 = sqrt(8)
So output for customer2 is 1
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6|
Fetching successful submissions