First: I admit that its a part of programming contest(where nothings on a stake to win or something)
I've come to the following conclusion after reading the problem & tried following algorithm.
Given Undirected Connected Graph of n
vertices,
count = 0
For i=1 to n:
remove(ith vertex)
check for connectivity of graph with remaining vertices
if connected
then increment count
attach the removed vertex back
print count
I've implemented this by two ways: (1) DFS (2) Disjoint-Set Union but none of the algorithms are efficient enough to get AC. Does there exist even better ways to do so? I don't need detailed explanations, few words will do, rest I'll figure out or die trying :p. Thank You!