I tried to solve this problem using the technique mentioned in the editorial i.e, I found all the articulation points in the graph using dfs algorithm and multiplied it buy the cost k to get the final answer. But I am getting the error “Time Limit Exceeded”.

Anybody help me out resolving this.