#Q85. 「一本通 3.3 例 2」双调路径

「一本通 3.3 例 2」双调路径

Description

Original Source: BalticOI 2002

Road toll systems are rapidly evolving. With the increasing density of roads, choosing the optimal path has become a practical concern. The roads in the city are bidirectional, and each road has a fixed travel time and a cost associated with it.

A path consists of a sequence of connected roads. The total time is the sum of the travel times of the individual roads, and the total cost is the sum of the costs of the roads traversed. A path is considered better if it is either faster or cheaper than another path. More precisely, if a path is strictly faster and not more expensive, it is better. The converse also holds true. If no other path is better than a given path, that path is called a minimal path.

There may be multiple such minimal paths or none at all.

Problem: Read the network and compute the total number of distinct minimal paths. Two minimal paths with identical cost and time are considered the same. You only need to output the count of distinct minimal paths.

Input Format

The first line contains four integers: the total number of cities nn, the total number of roads mm, the starting city ss, and the destination city ee;

The next mm lines each describe a road with four integers: the two endpoints pp and rr, the cost cc, and the time tt;

There may be multiple roads connecting the same pair of cities.

Output Format

A single integer representing the total number of distinct minimal paths.

Sample 1

Sample input as shown below:

bic.png

There are 4 paths from 11 to 44. They are 1241\to 2\to 4 (cost 44, time 55), 1341\to 3\to 4 (cost 44, time 55), 12341\to 2\to 3\to 4 (cost 66, time 44), and 13241\to 3\to 2\to 4 (cost 44, time 1010).

1341\to 3\to 4 and 1241\to 2\to 4 are better than 13241\to 3\to 2\to 4. There are two optimal paths: one with cost 44 and time 55 (1241\to 2\to 4 and 1341\to 3\to 4) and another with cost 66 and time 44 (12341\to 2\to 3\to 4).

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

Data Range and Hints

For all data, $1\le n\le 100,0\le m\le 300,1\le s,e,p,r\le n,0\le c,t\le 100$. It is guaranteed that ses\not =e and prp\not =r.