How to solve this task, I tried with Dijkstra's algorithm but it fails on 14,15,16,17,18,19,20 test case on time...
z-teleport
sort the distances an add one by one until earth and zearth are connected
To sort them by distance to what ?
To sort distances from every point to every point and then go from earth to closest and so on to closest till I find Zearth?
To sort distances from every point to every point and then go from earth to closest and so on to closest till I find Zearth?
sort all distances between every two planets and look at platens as nods that you are connecting by adding these connections (that you have sorted) and when you add one that connects earth and zearth you have found the answer
not the one that connects exactly earth and zearth but the one that is connecting groups of nodes where are earth and zearth
Thanks for replay...But I've done it on the other way...
I've done some strange modifications on dijkstra algorithm and it passed :D
I've done some strange modifications on dijkstra algorithm and it passed :D