#K94837. Resilient Communication Network
Resilient Communication Network
Resilient Communication Network
You are given a network of anthills and potential bidirectional communication links connecting them. Each anthill represents a node and each communication link represents an edge. In order to guarantee that the network remains fully functional even if any single link fails, a command center must be placed at each anthill in a fully connected network.
In other words, if the network is fully connected (i.e. there is a path between every pair of anthills), then the minimum number of command centers required is equal to the number of anthills n. Otherwise, if the network is not fully connected, it is impossible to achieve the desired resilience.
Note: The anthills are numbered from 0 to n-1.
inputFormat
The first line contains two integers n and m, where n is the number of anthills and m is the number of communication links available.
This is followed by m lines, each containing two integers u and v, representing a bidirectional communication link between anthills u and v.
outputFormat
If the network is fully connected, print the number of anthills (n), which is the minimum number of command centers required. Otherwise, print impossible
(without quotes).
4 4
0 1
1 2
2 3
3 0
4
</p>