eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Cable TV Network

Cable TV Network

The interconnection of the relays in a cable TV network is bi-directional. The network is connected if there is at least one interconnection path between each pair of relays present in the network. Otherwise the network is disconnected. An empty network or a network with a single relay is considered connected. The safety factor \textbf{f} of a network with \textbf{n} relays is: \begin{enumerate} \item \textbf{n}, if the net remains connected regardless the number of relays removed from the net. \item The minimal number of relays that disconnect the network when removed. \end{enumerate} \includegraphics{https://static.e-olymp.com/content/97/97b3bfcefdc0465e748a49b7b87c8bb6603408e0.jpg} \textit{Figure 1. Cable TV Network} For example, consider the nets from figure \textbf{1}, where the circles mark the relays and the solid lines correspond to interconnection cables. The network (\textbf{a}) is connected regardless the number of relays that are removed and, according to rule (\textbf{1}), \textbf{f=n=3}. The network (\textbf{b}) is disconnected when \textbf{0} relays are removed, hence \textbf{f=0} by rule (\textbf{2}). The network (\textbf{c}) is disconnected when the relays \textbf{1} and \textbf{2} or \textbf{1} and \textbf{3} are removed. The safety factor is \textbf{2}. \InputFile Write a program that reads several data sets from the standard input and computes the safety factor for the cable networks encoded by the data sets. Each data set starts with two integers: \textbf{0} ≤ \textbf{n} ≤ \textbf{50}, the number of relays in the net, and \textbf{m}, the number of cables in the net. Follow m data pairs (\textbf{u}, \textbf{v}), \textbf{u} < \textbf{v}, where \textbf{u} and \textbf{v} are relay identifiers (integers in the range \textbf{0..n-1}). The pair (\textbf{u}, \textbf{v}) designates the cable that interconnects the relays \textbf{u} and \textbf{v}. The pairs may occur in any order. Except the (\textbf{u}, \textbf{v}) pairs, which do not contain white spaces, white spaces can occur freely in input. Input data terminate with an end of file and are correct. \OutputFile For each data set, the program prints on the standard output, from the beginning of a line, the safety factor of the encoded net.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
0 0
1 0
3 3 (0,1) (0,2) (1,2)
2 0
5 7 (0,1) (0,2) (1,3) (1,2) (1,4) (2,3) (3,4)
Выходные данные #1
0
1
3
0
2
Источник SEERC 2004