Package delivery is really a tiring work. I’m spending all day on the roads, crossing bridges and highways through the city, and visiting various people in different buildings. Anytime someone asks me if I’m busy, stressed or overworked and the answer will likely be an emphatic yes.
But I have my experience in my job. At the beginning of the day, I arrive at the company and receive the packages of today’s work. Before I set out to deliver them, I have to carefully consider which package should be sent first and which way I should go. It’s really a heavy headache for me.
The city consists of totally M two-way roads,
each of which is a straight segment line or a circle. A straight one contains two endpoints that can be denoted as A
i(x
iA,y
iA) and B
i(x
iB,y
iB) on a two-dimensional map, while a circle-shaped road should be expressed as a centre point O
i(x
i,y
i) and its radius Ri. Roads may cross with others (even on the endpoint), but no two roads will overlap. The coordinates and radius are measured in centimetre (cm) and the scale of the map is
1: 100000. That is, two locations with actual distance of 1 kilometre (km) will be 1cm apart on the map. Further more, roads are not neccessarily connected in the city.
My company locates at (C
x,C
y) on the map. As I said before, I will occur there at the beginning of the day. When I set out from somewhere and leave for the next destination, I have two choices: on foot, or by taxi (don’t laugh at me anyway). My walking speed keeps at V
walk km/h and it won’t change. However, car speed limit differs on every road due to the different traffic situations. Cars can only run along the roads rather than other areas, while walking is of no constraints.
If I choose to walk to the next destination, I go there directly along a straight line from start to target and will not stop on the way. But taking a taxi is a little bit complicated. Firstly I’ll choose a road, and walk to
the nearest position from me on that road. If there’s a tie, all candidates are available. After waiting for a taxi for T
wait minutes, I step on a taxi at that position and choose a road as my target. The car will run along the roads and send me to the target road, and I’ll get off the taxi at the nearest location to the destination on that road. Finally, I walk from where I get off the taxi along a straight way to the destination, and will not take another taxi any more (even it might be faster, but it costs money for me). Because of my urgent demands, the taxi always runs at limit speed on every specific road. But the taxi drivers are not well enough - I have to determine the way myself to prevent being ripped off.
N packages’ destinations spread all over the city. The ith package’s destination locates at P
i(x
i,y
i) which may occur at any corner of the city except on any roads. Besides, there’s an urgency degree for each package, denoted by U
i. Customers are always troubles, and hence my mission is certainly to try my best minimizing their dissatisfaction. If Package i arrives at the destination by t
i minutes since I set off from the company, the specific customer’s dissatisfaction should be U
i * t
i.
I’m going to minimize the sum of all dissatisfactions. How should I determine the order of deliveries and the tour plan to accomplish the mission?
The input contains several test cases. The number of test cases T (T<=10) occurs in the first line of input.
For each test case:
The first line contains N , M , V
walk and T
wait.
The following line gives the company’s coordinates C
x,C
y .
The following N lines describe the packages, where the ith line contains x
i,y
i,U
i, indicating that package i locates at P
i(x, y) with a urgency degree U
i.
The following M lines describe the roads. Two formats are potential:
a)Line x
iA y
iA x
iB y
iB v
i: line-shaped road whose endpoints are A
i(x
iA,y
iA) and B
i(x
iB,y
iB).
b)Circle x
i y
i R
i v
i: circle-shaped road whose centre is O
i(x
i, y
i) with a radius of R
i.
Here, v
i denotes the limit speed for the ith road, measured in km/h.
Scales:
1<=N<=15
1<=M<=30
0.01<=V
walk<=10.00, 0.01<=v
i<=120.00, 0.01<=T
wait<=60.00
0.01<=U
i, R
i<=1000.00.
The coordinates, radius, time and speed are float numbers and will be rounded in 2 decimals. The absolute value of coordinates doesn’t exceed 1000.
For each test case, output the minimal sum of dissatisfactions in a line, rounded in 2 decimals.
The test data guarantees that answers will not exceed 10
7.