P3039 [USACO12JAN] Delivery Route S
Description
After several years of record milk production, Farmer John now operates an entire network of N farms (1
Input Format
* Line 1: The number of farms, N.
* Lines 2..1+N: Line i+1 contains two space-separated integers, x_i and y_i (1
Output Format
* Line 1: The minimum number of minutes FJ needs to complete his delivery route, or -1 if it is impossible to find a feasible delivery route that visits every farm exactly once (except farm 1).
Explanation/Hint
FJ can complete his delivery route in 12 minutes: 2 minutes to go from farm 1 to farm 2, 5 minutes to go from farm 2 to farm 3 (circumventing farm 1), 3 minutes to go from farm 3 to farm 4, and then 2 minutes to return to farm 1.