eolymp
bolt
Try our new interface for solving problems
Problems

Attack of the Giant n-pus

Attack of the Giant n-pus

A pirate ship is being attacked by a giant \textbf{n}-pus^1. The \textbf{n} tentacles and the head of the creature have pierced the deck and are wreaking havoc on the ship. In an attempt to stop the creature from completely destroying the ship, the captain charges towards the head of the creature. Unfortunately, he quickly gets knocked back by one of the tentacles. The captain realizes he cannot attack the head of the n-pus as long as it can move its tentacles freely. Luckily the captain is not alone on the ship. There are \textbf{p} (\textbf{p} ≥ \textbf{n}) pirates spread around on the deck, ready to follow the captain's orders. So the captain comes up with the following plan. If each tentacle is attacked by one of the pirates, he can move freely towards the head of the creature and finish it. To be safe, the captain will start moving only after each of the tentacles is being attacked by a pirate. When the captain reaches the head, he can instantly kill the creature. The captain wants to figure out which pirates to send to which tentacles, such that the creature can be killed as fast as possible. As this happens regularly to pirates, the captain wants you to write a program to solve this problem. ____________ ^1 - An \textbf{n}-pus is like an octopus, but then with \textbf{n} tentacles. \InputFile The first line of the input contains the number of test cases to follow. Each test case has the following format: \begin{itemize} \item One line with two integers \textbf{n }and \textbf{p}, satisfying \textbf{1 }≤ \textbf{n }≤ \textbf{p }≤ \textbf{100}: the number of tentacles of the \textbf{n}-pus and the number of pirates (excluding the captain), respectively. \item One line with three integers \textbf{x_c}, \textbf{y_c} and \textbf{v_c}: the captain's coordinates and speed, respectively. \item \textbf{p }lines, each with three integers \textbf{x_i}, \textbf{y_i} and \textbf{v_i}: the coordinates and speed, respectively, of each pirate. \item One line with two integers \textbf{x_h} and \textbf{y_h}: the coordinates of the head of the \textbf{n}-pus. \item \textbf{n }lines, each with two integers \textbf{x_j} and \textbf{y_j}: the coordinates of each tentacle. \end{itemize} All coordinates satisfy \textbf{0 }≤ \textbf{x}; \textbf{y }≤ \textbf{10000}. All speeds satisfy \textbf{1 }≤ \textbf{v }≤ \textbf{100}. The captain, the pirates, the head and the tentacles are all considered to be point-like (i.e. they have no size). Their locations are all distinct. The captain and all pirates move to their target in a straight line at their given speed and are not hindered by anyone or anything. \OutputFile For every test case in the input, the output should contain one floating point number on a single line: the minimum time it takes for the captain to kill the \textbf{n}-pus. Your answer should have either an absolute or a relative error of at most \textbf{10^\{-6\}}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
3 3
2 0 1
0 0 2
1 0 3
3 0 4
2 3
0 1
1 1
4 1
1 3
0 0 1
3 0 1
4 0 1
7 0 2
0 1
4 2
3 3
0 0 2
2 0 3
3 0 1
4 0 2
0 1
3 1
4 1
5 1
Output example #1
3.5
2.802775638
1.5
Source 2011 Benelux Algorithm Programming Contest, Preliminaries, Problem C