Page 2 of 2

Re: 11286 - Conformity

Posted: Sun Aug 24, 2014 10:46 am
by Repon kumar Roy
Can you tell me ? how the output of the second case is 3 ?? What is the combination ?

I didn't find what actually is told to compute ?

Re: 11286 - Conformity

Posted: Tue Aug 26, 2014 11:48 pm
by brianfry713
Every combination has one student taking it, so they are all the most popular.

Re: 11286 - Conformity, Getting WA, Need Help...

Posted: Sun Jan 25, 2015 7:11 pm
by garbage

Code: Select all

#include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;

string sortedString(string ch)
{
    int len = ch.length();
    
    for(int i=0;i<len-1;i++)
    {
        for(int j=i+1;j<len;j++)
        {
            if(ch[i]>ch[j])
            {
                char t = ch[i];
                ch[i] = ch[j];
                ch[j] = t;
            }
        }
    }
    return ch;
}

int main()
{
    long n;
    string ch;
    
    while(cin>>n)
    {
        if(n == 0)
            break;
        
        map<string, long>myMap;
        map<string, long>::iterator it;
        
        long mx = 0;
        for(long i=1;i<=n;i++)
        {
            string S, total = "";
            for(int j =1;j<=5;j++)
            {
                cin>>ch;
                total = total + ch;
            }
        
            S = sortedString(total);
            
            myMap[S]++;
            
            if(mx < myMap[S])
                mx = myMap[S];
        }
        
        long cnt = 0;
        for(it = myMap.begin(); it!=myMap.end();it++)
            if(it->second == mx)
                cnt += it->second;
                
        cout<<cnt<<endl;
    }
    return 0;
}

Re: 11286 - Conformity

Posted: Tue Jan 27, 2015 3:27 am
by brianfry713
Input:

Code: Select all

3
100 101 102 103 488
100 101 102 103 488
110 111 200 388 400
0
Output should be 2

Re: 11286 - Conformity

Posted: Tue Jan 27, 2015 8:27 am
by garbage
thnx brianfry713... :)