#P2097. Minimum Data Input for Full Propagation
Minimum Data Input for Full Propagation
Minimum Data Input for Full Propagation
There are several computers, and some pairs of computers are connected by bidirectional cables. If one computer receives data, it can pass the data to all directly connected computers, and this propagation continues.
Given the network of computers, determine the minimum number of computers that must be manually fed with data so that every computer eventually receives the data.
Note: The connections form an undirected graph. The answer is the number of connected components in the graph.
inputFormat
The first line contains two integers n and m, where n is the number of computers and m is the number of bidirectional cables.
Each of the following m lines contains two integers u and v (1 ≤ u, v ≤ n), which indicates that there is a cable between computer u and computer v.
outputFormat
Output a single integer that represents the minimum number of computers to which the data must be input manually so that all computers eventually receive the data.
sample
3 1
1 2
2