Company: Wells_Fargo
Difficulty: medium
Farmer's Shortest Path Problem Problem Description The farmer wants to return home, Farm No. 1, from Farm No. N. The farmer is very tired and wants to return home as fast as possible. In the farms he cultivates, there are T two-way roads. Create a program that helps the tired farmer find the shortest distance from Farm No. N to Farm No. 1. Examples Example 1: Input: 5 5 1 2 20 2 3 30 3 4 50 4 5 70 1 5 200 Output: 120 Explanation: The problem requires finding the shortest path from Farm N (which is Farm 5 in this example) to Farm 1 using the provided two-way roads and their respective lengths. Constraints The first line of input contains two integers: T (number of roads) and N (number of farms). 1 ≤ T ≤ 10000 1 ≤ N ≤ 1000 Each of the next T lines contains three integers: S , E , and D , representing a two-way road between farm S and farm E with length D . 1 ≤ S, E ≤ N 1 ≤ D ≤ 100 Farms are numbered from 1 to N.