Score : $500$ points
The Kingdom of AtCoder has $N$ cities called City $1,2,\ldots,N$ and $M$ roads called Road $1,2,\ldots,M$.
Road $i$ connects Cities $A_i$ and $B_i$ bidirectionally and has a length of $C_i$.
One can travel between any two cities using some roads.
Under financial difficulties, the kingdom has decided to maintain only $N-1$ roads so that one can still travel between any two cities using those roads and abandon the rest.
Let $d_i$ be the total length of the roads one must use when going from City $1$ to City $i$ using only maintained roads. Print a choice of roads to maintain that minimizes $d_2+d_3+\ldots+d_N$.
Input is given from Standard Input in the following format:
$N$ $M$ $A_1$ $B_1$ $C_1$ $A_2$ $B_2$ $C_2$ $\vdots$ $A_M$ $B_M$ $C_M$
Print the indices of roads to maintain, in arbitrary order, with spaces in between.
If multiple solutions exist, you may print any of them.
3 3 1 2 1 2 3 2 1 3 10
1 2
Here are the possible choices of roads to maintain and the corresponding values of $d_i$.
Thus, maintaining Road $1$ and $2$ minimizes $d_2+d_3$.
4 6 1 2 1 1 3 1 1 4 1 2 3 1 2 4 1 3 4 1
3 1 2