For find out second best spanning tree is needed to first build mst tree and for each edge from mst tree flag them then again run kruskal. But how to find second best spanning tree only using union find data structure or lca. I want to know both ways :( Thanks in advance :)
Is there yet any answer to that by using only DSU? LCA answers are widely known and appear everywhere, but I have seen nowhere anything using the DSU generated by Kruskal (without path compression of course, since path compression destroys the useful information)...
I wrote this as my homework years ago. For problem that can be solved by similar idea, you can check 1023F - Mobile Phone Network and my submission 67434523.
Thanks for the PDF link.
check this submission 15317414 DSU only