Critical Networks
A network is said to be disconnected if there are at least two nodes a, b such that there is no path connecting a and b.
The degree of a node x in a network is the nuber of other nodes which are directly adjecent to x.
Whenever a node is removed from a network all its adjacent edges are removed from the network too.
A network is said to be D-critical if it becomes disconnected after removing all nodes of degree D.
Image 1. Examples of networks. The examples correspond to the data of Example 1, 2 and 3 below. The network in case a) is 3-critical. It is not 2-critical and it is not 4-critical. The network in case b) is 4-critical and it is not 2-critical. The network in case c) is 2-critical. Also, it is 3-critical and 5-critical and not 4-critical. |
Â
The task
You are given a network scheme. List all values of D for which the network is D-critical.
Input
The first input line contains two integers N and E separated by space. The values indicate (in this order) the number of nodes in the network and the number of direct connections between the nodes in the network. The nodes are labeled by integers 0, 1, ..., N−1.
Next, there are M text lines, each describe one pair of directly connected nodes. Each line contains the labels of two nodes separated by space. The order of node labels in a pair and the order of pairs of nodes in the input is arbitrary.
It holds, 3 ≤ N ≤ 103.
Output
The output contains one text line with a list of integers separated by space and sorted in ascending order. The integers represent all values of D for which the given network is D-critical. You may assume that at least one such D exists in all given data.
Example 1
Input9 12 0 1 1 2 3 4 4 5 6 7 7 8 0 3 1 4 2 5 3 6 4 7 5 8Output
3The data and solution of Example 1 are depicted in Image 1a).
Example 2
Input10 15 0 1 1 2 3 4 4 5 6 7 7 8 8 9 0 3 2 5 3 6 3 7 4 7 4 8 5 8 5 9Output
4The data and solution of Example 2 are depicted in Image 1b).
Example 3
Input9 12 0 1 0 2 0 3 0 4 1 5 2 5 3 5 4 5 5 6 6 7 7 8 8 6Output
2 3 5
Public data
The public data set is intended for easier debugging and approximate program correctness checking. The public data set is stored also in the upload system and each time a student submits a solution it is run on the public dataset and the program output to stdout and stderr is available to him/her.
Link to public data set