Uva 11286 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i;
    map<string, int>mp;
    string s[5];
    string ch = "";
    while(cin >> n && n != 0)
    {
        for(i=1;i<=n;i++)
        {
            cin >> s[0] >> s[1] >> s[2] >> s[3] >> s[4];
            sort(s, s+5);
            ch = s[0] + s[1] + s[2] + s[3] + s[4];
            mp[ch]++;
        }
        int mx = 0, c = 0;
        for(auto it = mp.begin(); it!=mp.end(); it++)
        {
            if(it->second > mx)
            {
                mx = it->second;
                c = 0;
            }
            if(mx == it->second)
            {
                c += mx;
            }
        }
        cout << c << "\n";
        mp.clear();
    }

    return 0;
}

Comments