Processing math: 100%
Connected component - MarisaOJ: Marisa Online Judge

Connected component

Time limit: 1000 ms
Memory limit: 256 MB
Given a undirected graph of n vertices and m edges. Count the number of connected components in this graph. ### Input - The first line contains 2 integers n,m. - The next m lines, each line contains 2 integers u,v, there is an edge between those vertices. ### Output - Print the number of connect components. ### Constraints - 1≤n,m≤105. - 1≤u,v≤105. ### Example Input: 5412132345 Output: 2