#P11716. Destroy the Spies: Camera Elimination
Destroy the Spies: Camera Elimination
Destroy the Spies: Camera Elimination
One day, the City of Wisdom was attacked by the anti-human intelligences. They set up \(N\) cameras in the city in an attempt to monitor everyone. In order to locate and destroy the cameras, the heroes decided to use a mysterious transmitter designed using the Extended Cardano Constant Principle. When placed at a certain position and set with a specific radius, the transmitter detects any target lying exactly on the surface of the sphere whose center is at the transmitter's location and whose radius is the specified value. This sphere is given by the equation
\( (x-c_x)^2 + (y-c_y)^2 + (z-c_z)^2 = r^2 \)
During a series of experiments with the transmitter, exactly one camera was detected in each experiment. However, due to some cameras being relocated during the experiments, the feedback did not match the final positions of the cameras. Eventually, the final positions of all \(N\) cameras were determined, but nobody could recall which camera was detected in each experiment.
Your task is: Given the final positions of the \(N\) cameras and the experimental data (i.e. the transmitter's center \((c_x, c_y, c_z)\) and the detection radius \(r\) used in each experiment), find out the index (1-indexed) of the camera that was detected in each experiment.
inputFormat
The input begins with two integers \(N\) and \(M\) where \(N\) is the number of cameras and \(M\) is the number of experiments.
Then follow \(N\) lines, each containing three integers \(x\), \(y\), \(z\) representing the final position of each camera.
Then follow \(M\) lines, each containing four integers: \(c_x\), \(c_y\), \(c_z\) and \(r\), representing the transmitter's position and the radius used in that experiment.
It is guaranteed that for every experiment, there is exactly one camera such that
\( (x-c_x)^2 + (y-c_y)^2 + (z-c_z)^2 = r^2 \)
outputFormat
For each experiment, output the index (1-indexed) of the camera that satisfies the equation above. Each answer should be printed on a new line.
sample
3 2
0 0 0
3 4 0
0 5 12
0 0 0 0
0 0 0 5
1
2
</p>