#P8017. [COCI 2013/2014 #4] UTRKA
[COCI 2013/2014 #4] UTRKA
Problem Description
Mirko and Slvako are taking part in a racing competition. The map for this competition has villages and roads. For the -th road, there are two parameters and , which represent the time Mirko and Slvako need to pass through this road, respectively.
The race starts and ends at the same village. Now you need to find a route such that Mirko’s time on this route is as much better as possible than Slvako’s time on this route.
In other words, let be the time Mirko needs to finish the route, and be the time Slvako needs to finish the route. You need to find a route that uses as few villages as possible, and among those routes, makes as large as possible.
Input Format
The first line contains two positive integers and , meaning there are villages and roads.
The next lines each contain four positive integers , meaning the -th road connects village and village . The time for Mirko to pass this road is , and the time for Slvako to pass this road is .
Output Format
Output one line with two positive integers: the number of villages on the required route, and the value of for the route that maximizes among all routes with the minimum number of villages.
3 4
1 2 3 0
2 3 3 0
3 1 0 100
2 1 0 4
2 1
5 7
1 2 4 1
2 3 5 1
3 1 1 6
1 3 15 5
2 4 7 5
4 5 1 4
5 3 1 0
5 2
Hint
Constraints
For of the testdata, , , , .
Source
The score of this problem follows the original COCI settings, with a full score of .
This problem is translated from COCI2013-2014 CONTEST #4 T6 UTRKA.
Translated by ChatGPT 5