Gregor is a salesperson employed in the city of Cartesia, which lies on an infinite plane. The locations of retailers follow the Cartesian coordinate system.
There are N + 1 retailers in the city:
Gregor wants to find the shortest possible path starting from the K-th retailer and visiting all the other retailers exactly once. He may visit the head retailer twice during the route.
The distance between two retailers is the Euclidean distance between their corresponding Cartesian coordinates.
Print the minimum possible path length, rounded to 6 decimal places.
double minPossLen(
int posK,
vector<int> retailerXCoord,
int headXCoord,
int headYCoord
);
Print a single floating-point number representing the minimum possible path length, rounded to 6 decimal places.
1
3
0 1 2
1
1
3.828427
Retailers are located at:
Head retailer is at:
Starting retailer:
One minimum path is:
(0,0) → (1,1) → (0,0) → (1,0) → (2,0)
Path length:
√2 + √2 + 1 + 1
= 1.4142135 + 1.4142135 + 1 + 1
= 3.828427
Hence, the minimum possible path length is:
3.828427
Jefeeerirs • Pending
Jefeeerirs • Pending
Jefeeerirs • Pending
Texas • Pending