Problem Link : http://codeforces.com/problemset/problem/721/A
In a nutshell, this problem simply asks you to list down how many lines of black squares, and their lengths.
A simple iteration would do. Just don’t forget to check after the end of iteration if your counter still have some length in them – print them out. Doing so would also take care of a case where there is only one line of black squares.