#C3792. Critical Roads in the City

    ID: 47258 Type: Default 1000ms 256MiB

Critical Roads in the City

Critical Roads in the City

You are given a network of buildings connected by bidirectional roads. The city is represented as an undirected graph with n buildings and m roads. Your task is to identify all the critical roads (also known as bridges) in the city. Removing a critical road increases the number of connected components in the graph.

In graph theory terms, for each road connecting buildings u and v, if after removal there is no alternative path between u and v, then the road is critical. The algorithm typically uses a Depth-First Search (DFS) and maintains two arrays: the discovery time ids and the low time low, where the condition for a critical road is given by the formula:

$$ ids[u] < low[v] $$

If no critical roads exist, output a single line with the string None.

inputFormat

The first line of input contains two integers n and m, representing the number of buildings and roads respectively. Each of the following m lines contains two integers u and v, indicating a bidirectional road between buildings u and v.

outputFormat

If the graph contains critical roads, output each critical road on a separate line in sorted order (with the smaller building number printed first). If there are no critical roads, output a single line containing 'None'.## sample

5 5
1 2
1 3
2 3
3 4
4 5
3 4

4 5

</p>