Description
Connected component
Input (Standard input)
In the first line, the number of vertices N (1 ≤ N ≤ 1,000) is given.
From the next line, the adjacency list of graph G is represented as the two integers x, y. This means the edge from vertex x to vertex y exists.
Output (Standard output)
In the first line, print the number of connected components.
In the next N lines, print the component number of each vertex.
[Example]
Input Output
6
1 2
1 4
2 5
3 6 2
1
1
2
1
1
2
Description
1. File name must be Connected_component.cpp
2. Make a comment of your student ID, name and class in the first line of the source code. ex) 2014601028_Honggildong_A
3. Please keep the source code that you have submitted for some unexpected accident.




Reviews
There are no reviews yet.