#P6436. 「EZEC-1」越狱
「EZEC-1」越狱
Description
Little E's escape route can be viewed as occurring on islands. These islands are connected pairwise by sea routes, forming a tree.
Each island has enough supplies. Assume that for every day he sails at sea, he must spend unit of food. A greedy shop owner states that a backpack that can hold units of food will be sold for ten-thousand yuan.
PF may order the construction of a bidirectional sea route between any two islands and that satisfy both conditions: the travel time between them is not greater than , and on the route from island to island there are at least islands ( excluding and ). The travel time of this new route is . Due to budget issues, he can build only one extra route.
Little E can use the official routes ( including the newly added route ) to determine PF's shortest time to each island.
PF will discover Little E's escape at time and then start the pursuit.
To save money while escaping PF's chase, Little E wants you to write a program to compute the minimum such that he can successfully escape to at least islands.
Supplying does not take time. Getting caught on the way still counts as getting caught. Arriving at the same time does not count as being caught.
Replenishing supplies on an island takes no time and can be done infinitely many times, as long as the backpack has enough capacity.
Problem summary:
There are two people and and a tree with nodes. starts seconds earlier than . If the travel time between two nodes is not greater than , then can build a route between these two nodes with travel time . Find a plan such that 's shortest time to at least nodes is not longer than 's, and on this basis, make the maximum distance between islands as small as possible.
Input Format
The first line contains five integers , representing the number of islands, the time when PF discovers the escape, the travel-time limit required to build a route, the minimum number of islands that must be reachable, and the required number of intermediate islands for building a route. Both of their starting points are node .
The next lines each contain four integers , indicating that there is a route between islands and . is the time for Little E to travel along this route, and is the time for PF to travel along this route. Routes are bidirectional.
Output Format
If there is a solution, output two lines.
The first line contains an integer , indicating the minimum amount of money needed to escape (unit: ten-thousand yuan).
The second line contains an integer , indicating the number of islands that can be reached when buying a backpack costing (node also counts).
If there is no solution, output only no solution.
5 3 20 4 2
1 2 5 5
2 3 5 5
2 4 7 10
1 5 4 1
7
4
5 2 6 3 2
1 2 5 3
2 3 8 6
1 4 8 2
2 5 4 6
5
3
5 0 23 4 1
1 2 21 26
1 3 14 16
3 4 4 5
1 5 19 18
no solution
Hint
[Sample Explanation]
Sample :

For sample , the final reachable nodes are , and the minimum cost is . Since warden PF goes from node along the path , the number of intermediate nodes is , so warden PF can add an edge between nodes and . If warden PF chooses to add the edge , then the time to reach node is $3 + 1 + \left\lfloor \dfrac{1+5+5}{2}\right\rfloor = 9$. However, Little E's shortest time to node is , which does not satisfy the condition. Therefore, no matter how large is, node is unreachable.
[Constraints]
| Test Point ID | Time Limit | Memory Limit | Feature | ||||
|---|---|---|---|---|---|---|---|
| Adding an edge does not affect the answer | |||||||
| None | |||||||
| Adding an edge does not affect the answer | |||||||
| None | |||||||
| Adding an edge does not affect the answer | |||||||
| None | |||||||
For of the data, , , , , , .
It is guaranteed that the number of possible plans for the newly built bidirectional route does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号