Computing MDSST
Time limit1sMemory limit512 MB
Given a complete weighted graph on at most 15 vertices, find the spanning tree whose sum of all pairwise shortest-path distances is smallest, and print that sum.
- Level
Hard8 of 10
- Topics
- Graph, Minimum spanning tree, Brute force, Bit manipulation
- Solved
- No attempts yet
Problem
In this problem we consider weighted undirected graphs where every edge has positive weight.
Let be the length of the shortest path in graph between vertex and vertex .
We are given a complete weighted undirected graph with vertices numbered from to . Among the spanning trees of , the MDSST (Minimum Distance Sum Spanning Tree) is the tree that minimizes . Find the MDSST of and print .
Input
The first line contains an integer , the number of vertices in the graph (). The -th of the following lines contains integers separated by spaces. The -th integer on this line is the length of the edge between vertex and vertex .
All lengths are between and , inclusive.
Output
On the first line, print one integer: the value for the MDSST you found.