Hi Everyone! I encountered a problem a few weeks ago and came up with an idea but I got TLE (explained in the comments) and idk how to make it better. Will you plz help me solve it?
The problem statement is as follows:
We have decided to add signs to the map for logistics team drivers to use. A simplified model of the map is defined as a graph in which all the edges of the street are two-sided and the vertices represent positions with unique names.
For this reason, John :) intends to add a sign to the map called "Obligatory turn!". Consider street e connects position v to position w. At position vs entrance to street e an "Obligatory turn!" sign will be installed if by entering street e from v, the driver has to turn 180 degrees to return to position v.
Also, to simplify the map, we intend to add the minimum number of "Obligatory turn!" signs. We do this with the rule that if at the entrance of the position v to street e an "Obligatory turn!" is installed and at the entrance of position x to street f another "Obligatory turn!" is installed too, assuming that entering from position v and passing through street e it is possible to reach position x and then to street f without making any turns, then the sign "Obligatory distance!" from x is not necessary and should be deleted.
In this question, John asks you to help him find the places where we should install this sign. 
INPUT
In the first line of the input, two numbers are given, m and n, where n is the number of positions(nodes) and m is the number of streets(edges). In the next m lines, the numbers v and w are given, indicating that there is a two-way street between the positions v and w. Also, all pairs of positions are unique at the input.
1 <= n,m <= 5*10^5
OUTPUT
In the first line, output k, which indicates the number of signs required. In the next k lines, output two integers each line, v and w, indicating that the "Obligatory turn!" sign must be installed at the entrance of the position v to the street between v and w. The output lines of the position of the signs should be printed in ascending order with respect to v, and in term of equality of vs, ascending with respect to w.
TEST CASE 1
INPUT
6 5
1 2
1 3
2 3
4 5
5 6
OUTPUT
2
4 5
6 5
TEST CASE 2
INPUT
8 8
1 2
1 3
2 3
3 4
1 5
1 6
6 7
6 8
OUTPUT
3
1 5
1 6
3 4








My solution is to find critical edges in the graph (edges that by removing them, graph will be converted into 2 connected parts) and then in these edges, find which one of the two sides we should put the sign and then finally try to eliminate additional signs according to the problem statement.
So, what youre describing is exactly a bridge on a graph. If this is the quadratic part in your algorithm, you should look this up https://cp-algorithms.com/graph/bridge-searching.html