#C1535. Finding Critical Nodes in a Network

    ID: 44751 Type: Default 1000ms 256MiB

Finding Critical Nodes in a Network

Finding Critical Nodes in a Network

You are given an undirected network with n nodes and m edges. Your task is to find all the critical nodes (articulation points) in the network. A critical node is one whose removal increases the number of connected components in the network.

Consider the network represented as an undirected graph. Use Depth First Search (DFS) and low-link values to determine which nodes are articulation points.

Note: The input graph might be disconnected. Ensure that your solution handles all components of the graph.

Input Format: The first line contains two integers n and m. The next m lines each contain two integers u and v representing an edge between nodes u and v.

Output Format: Print two lines. The first line is the number of critical nodes. The second line is a sorted list of the critical nodes separated by a space.

inputFormat

The first line contains two space-separated integers n and m. Each of the next m lines contains two integers u and v representing an undirected edge.

outputFormat

The first line of the output is an integer representing the number of critical nodes. The second line contains the sorted critical node numbers separated by a space.## sample

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

1 3

</p>