Task:
You are given an undirected unweighted graph and one of its vertexes.
Count the number of its connected components.
Input:
The first line contains a natural n (1 ≤ n ≤ 100) – the quantity of the graph’s vertexes.
The next n lines contain the adjacency matrix of the graph (0 means no edge, 1 means the edge exists).
Output:
The first line should contain the number of connected components.
The next each line should contain the length of a connected component, then the component itself.
Example:
Input |
Output |
4 0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 |
2 3 1 2 3 1 4 |