WA in GALACTIK Please Help!

Checked all previous links in the forum for this question… but unable to debug…
I’m doing dfs to find min tax val node in each component(val>=0) and then using it to construct optimum edges.
WA Code

Editorial link GALACTIK - Editorial - editorial - CodeChef Discuss
You need to find the vertex which has lowest cost of all vertexes. It will be in some component so we should connect all other components to that component to achieve minimum cost. Keep the sum total of all min tax val node of each component.
Total cost= minVal*(K-1) + (sum- minVal)

1 Like

Thanks for help :slight_smile: I missed this part… “We should connect all other components to that component to achieve minimum cost!”