I am new to Competitive Programming and I have a Graph problem as below, the limit of time is 3 seconds and the memory limit is 256 Mb.
An is observing an undirected graph. He wonders if there exits in this
graph 2 vertices that connecting these 2 vertices will create exactly
one more simple cycle. Recall that a simple cycle may be defined
either as a sequence of vertices with no repetitions of vertices and
edges allowed, other than the repetition of the starting and ending
vertex, with each two consecutive vertices in the sequence adjacent to
each other in the graph.
Your task is to help An count the number of pairs of vertices
satisfying the conditions above.
The first line consist of two positive integers n,m (n,m≤10^5)
which are the number of vertices and the number of edges of the given
Each line in the m following lines contains two positive integers u,v
(u,v≤n) which are two vertices connected by an edge.
You should output on a single line an unique integer that is
the number of pairs you found.
I am now having no idea about the way to solve this problem because I do not find any properties of pair-vertices which create more simple cycle in a given graph. I really need your help to build a proper algorithms.
I have a sample test case as below: