02 July 2015

UVA 11286 - Conformity (MAP)

/***
Md. Namzul Hasan
Shahjalal University of Science & technology,sylhet.
hasan08sust@gmail.com
Problem id : 11286
verdict: accepted
***/

#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cctype>
#include<sstream>
#include<stdlib.h>
#include<map>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
int main()
{
    map<string,in>mp ;
    vector<string> data ;
    map<string,in>::iterator it ;
    in n ;
    string str, s ;

    while(cin>>n && n)
    {
        in mx =0 ;
        for(in i=0 ; i<n ; i++)
        {
            str.clear() ;
            for(in j=0 ; j<5 ; j++)
            {
                cin>>s ;
                data.push_back(s) ;
            }

            sort(data.begin(), data.end()) ;

            for(in j=0 ; j<data.size(); j++)
            {
                str+=data[j] ;
            }

            mp[str]++ ;
            if(mx<mp[str])
                mx = mp[str] ;
            data.clear() ;
        }
        in cnt =0 ;
        for(it=mp.begin() ; it!=mp.end() ; it++)
        {
            if(it->second == mx)
                cnt = cnt + mx ;
        }
        pf("%d\n",cnt) ;
        mp.clear() ;
    }
    return 0 ;
}

No comments:

Post a Comment

UVA 10679 - I Love Strings!!