• + 0 comments

    We can solve using kruskal's approach + union-find (disjoint set). Whenever we are trying to add edge which leads to any of the machines we need to skip adding that edge and consider it in the answer.