luogu#P8068. [BalticOI 2002] Bicriterial routing (Day2)
[BalticOI 2002] Bicriterial routing (Day2)
Problem Description
You are given an undirected graph with vertices and edges. The length of an edge is a pair .
The length of a path is $(c_w, t_w) = (\sum_{e \in w} c_e, \sum_{e \in w} t_e)$.
A path is shorter than another path if and only if their lengths are different and .
Obviously, two paths may be incomparable, so there may be multiple shortest paths with different lengths between two vertices.
Find the number of distinct possible lengths among the shortest paths from to .
Input Format
The first line contains four integers .
The next lines each contain four integers , representing the two endpoints of an edge and its length.
Output Format
Output one integer on a single line, your answer.
4 5 1 4
2 1 2 1
3 4 3 1
2 3 1 2
3 1 1 4
2 4 2 4
2
Hint
Sample Explanation

Consider the following four paths:
- (length ).
- (length ).
- (length ).
- (length ).
Path 0 and path 1 are both shorter than path 3. There are two shortest-path lengths in total: (path 0, path 1) and (path 2).
Constraints
, , , .
Notes
BalticOI 2002 Day2 A.
Due to the configuration of the custom scoring script parameters, evaluation statuses other than AC, WA, TLE, and MLE are not supported for display. If you get any other evaluation status, you will receive UKE.
Subtask #0 is the sample; Subtask #1 is the full testdata.
Translated by ChatGPT 5