#1081: Shortest Path • time limit:10000msSingle Point time limit:1000msMemory Limit:256MB
Describe
On Halloween morning, Little Hi and Little ho, after a one-hour debate, finally decided how to spend a meaningful day-they decided to go to the haunted house!
After a number of hours in front of the haunted house, Little Hi and Little Ho, who had just entered the haunted house, were hungry, so they decided to use the map they had received before the door to find the shortest route to the end.
There are a total of n locations in the Haunted house, numbered 1, respectively. N, there are some road connections between these n locations, there may be multiple roads connected between the two locations, but there is no road where both ends are the same location. So little hi and Little ho at least how many miles to walk out of the haunted house to eat things?
Hint: Order! The order is the key. Input
Each test point (input file) has and has only one set of test data.
In a set of test data:
The 1th Act is 4 integers n, M, S, T, respectively, indicating the number of places in the haunted house and the number of roads, the number of the entrance (also a location), and the number of the exit (also a location).
The next M-line, each line describes a road: where the I behavior of three integers u_i, v_i, Length_i, indicates that there is a road length v_i between the place numbered U_i and the place numbered length_i.
For 100% of data, meet N<=10^3,m<=10^4, 1 <= length_i <= 10^3, 1 <= S, T <= N, and S not equal to T.
For 100% of the data, meeting little Hi and Little ho is always a way to get to the exit via the road marked on the map from the entrance.
Output
For each set of test data, output an integer ans, which means that little hi and Little ho are going to walk out of the haunted house at least.
-
-
Sample input
-
-
5 23 5 41 2 7082 3 1123 4 7214 5 3395 4 9601 5 8492 5 981 4 992 4 252 1 2003 1 1463 2 1061 4 8604 1 7955 4 4795 4 2803 4 3 411 4 6224 2 3622 3 4154 1 9042 1 7162 5 575
-
-
Sample output
-
-
123
AC Code:
hihoCoder-1081-Shortest Path • One (Dijkstra algorithm!!) )