ACM (TJU) : 2429


#include <iostream>
#include <algorithm>
using namespace std;

int main ()
{
    string input [20005];
    int n, m;

    while ( cin >> n >> m ) {

        if ( n == 0 && m == 0 )
            return 0;

        int frq [20005];
        for ( int i = 0; i < 20005; i++ )
            frq [i] = 0;

        for ( int i = 0; i < n; i++ )
            cin >> input [i];

        sort (input, input + n);

        string temp;
        int i = 0;

        while ( i < n ) {

            temp = input [i];
            int count = 0;
            while ( temp == input [i] ) {
                count++;
                i++;
            }

            frq [count]++;

        }

        for ( int i = 1; i <= n; i++ )
            cout << frq [i] << endl;

    }

    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