ACM (TJU) : 1090


// http://acm.tju.edu.cn/toj/showp1090.html

#include <stdio.h>

int main ()
{
    int n;
    int m;

    while ( scanf ("%d %d", &m, &n) != EOF ) {
        getchar ();
        char a [202] [202];

        for ( int i = 0; i < m; i++ )
            gets (a [i]);

        int frq [202] = {0};

        for ( int i = 0; i < n; i++ ) {
            int count = 0;
            for ( int j = 0; j < m; j++ ) {
                if ( a [j] [i] == '0' )
                    count++;
                else {
                    frq [count]++;
                    count = 0;
                }
            }

            if ( count )
                frq [count]++;
        }

        for ( int i = 1; i <= m; i++ ) {
            if ( frq [i] )
                printf ("%d %d\n", i, frq [i]);
        }
    }

    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s