Given a forest with n vertices, add edges to make it into a tree with minimal diameter. I tried many approaches but none of them passed system test cases.Please suggest some algorithm to solve this problem.
Given a forest with n vertices, add edges to make it into a tree with minimal diameter. I tried many approaches but none of them passed system test cases.Please suggest some algorithm to solve this problem.
The idea is to play with tree diameters while merging trees, you can use the ideas in the editorial for this problem (is very similar): http://codeforces.me/contest/455/problem/C
can you link the problem?
https://open.kattis.com/problems/adjoin
check the IOI 2013 Dreaming solution, it is almost the same problem.