Cable TV Network#3350

Cable TV Network

1 saniye
64 megabayt
Zor

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 of a network with relays is:

  1. , if the net remains connected regardless the number of relays removed from the net.

  2. The minimal number of relays that disconnect the network when removed.

Figure 1. Cable TV Network

For example, consider the nets from figure , where the circles mark the relays and the solid lines correspond to interconnection cables. The network (a) is connected regardless the number of relays that are removed and, according to rule (1), f=n=3. The network (b) is disconnected when relays are removed, hence f=0 by rule (2). The network (c) is disconnected when the relays and or and are removed. The safety factor is .

Giriş

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: 0 \le n \le 50, the number of relays in the net, and , the number of cables in the net. Follow m data pairs , u < v, where and are relay identifiers (integers in the range 0..n-1). The pair designates the cable that interconnects the relays and . The pairs may occur in any order. Except the 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.

Çıktı

For each data set, the program prints on the standard output, from the beginning of a line, the safety factor of the encoded net.

Örnekler

Örnek 1

Loading
Loading