So I have a program to write where it reads a file that contains a matrix so to say, so containing n lines of text. For example, the file would contain:

7 [ number of columns]
5 [ number of rows]
0000000
0001000
0011100
0001000
0000000

The program has to return the group size and the number of groups of that size.
So for this example it would be group size 5; with number of groups of size 5 is 1.

I am not sure how to approach this.
Would i scan each row, and once I hit a '1', enter it into a linked list? I am having trouble thinking about the adjacency part.