#P7702. [CCC 2014] 登机口
[CCC 2014] 登机口
Description
You are now in an airport with boarding gates, numbered from to . Gate is meters away from the airport entrance.
There are also horizontal moving walkways in the airport. The -th walkway moves one-way from gate to another gate at meters per minute. At any point in the corridor, in the same direction (toward the airport entrance or away from the airport entrance), there is at most one moving walkway in motion. However, it is possible that two moving walkways start from the same gate and have the same direction and the same destination.
You can walk along the corridor at speed meters per minute. When you are at the start of a moving walkway, you may choose to step onto it. If you do, it will take you to its endpoint. Even if a walkway passes through some position that is not its start or end, you cannot get on or off at that position. While you are on moving walkway , your speed is meters per minute.
While waiting for your delayed flight, for fun you ask yourself questions. The -th question asks for the shortest time to get from gate to gate . To make it more interesting, you decide that if you answer any question incorrectly, you will not board the plane, so you had better not mess it up.
Input Format
The first line contains four integers , representing the number of gates, walking speed, the number of horizontal moving walkways, and the number of queries.
The next lines each contain three integers , representing the start gate, end gate, and speed of moving walkway . Here .
The next lines each contain two integers , representing the start gate and the destination gate.
Output Format
Output lines. Each line contains one real number, the minimum number of minutes needed to go from gate to gate .
Your answer will be judged as follows: if is the standard answer, then any result in the range is considered correct.
6 10 3 4
2 3 15
4 2 150
3 6 290
3 2
2 3
1 4
4 6
10.0
4.0
24.0
6.25
Hint
For the first query, you only need to walk from gate to gate . The distance between the two gates is meters, and your speed is meters per minute.
For the second query, you should take the moving walkway from gate to gate . The distance is meters, and your speed is meters per minute.
For the third query, you should spend minutes walking to gate , then spend minutes taking the moving walkway described in query , and then spend minutes walking to gate .
For the fourth query, you should spend minutes taking the moving walkway from gate to gate , then spend minutes taking the moving walkway from gate to gate , and finally spend minutes taking the plane from gate to gate .
For some testdata, at least one of is small. This information may be useful, or it may not be.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号