Problem D
Rebel Portals

Sector quadrant MAPS-2019 has been the home of the Rebel Alliance ever since the beginning of the space war against the Galactic Empire. Now news has reached the Rebel Council that the Empire is conspiring to attack the Rebel planets in the quadrant. Unfortunately, existing communication technology does not enable a distress signal to reach all the planets in time to warn them of the upcoming invasion. Catherine has been appointed by the Council to pilot her spaceship to each Rebel planet and deliver the warning, and then return to her home planet.
Luckily for Catherine, the Rebel Alliance has been making progress towards developing portal technology that allows instant transportation between any two planets! Every Rebel planet is equipped with exactly one portal in case of an emergency such as this one. A spaceship that enters the portal on one planet immediately exits the portal on another planet (whichever planet the pilot chooses). However, there is still one glitch the Rebel scientists have not yet figured out: either entering or exiting a portal causes it to collapse on itself, so each portal can only be used once.
A planet is small enough relative to the size of the galaxy
that it can be represented as a single point in 3D space. The
distance between any two planets is measured as the Euclidean
distance between their representative points. To move from a
planet
Input
The first line of input contains an integer
Output
Output a single line containing the minimum total distance
Catherine needs to travel in order to visit every Rebel planet
and return to her home planet. Your answer will be accepted if
it is within
Sample Input 1 | Sample Output 1 |
---|---|
4 0 0 1 0 1 1 2 0 3 2 1 3 |
2.0 |
Sample Input 2 | Sample Output 2 |
---|---|
6 0 0 0 50 0 0 0 50 0 50 50 0 24 24 0 24 26 0 |
102.0 |