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 ?
11286 - Conformity
Moderator: Board moderators
-
- Learning poster
- Posts: 96
- Joined: Tue Apr 23, 2013 12:54 pm
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11286 - Conformity
Every combination has one student taking it, so they are all the most popular.
Check input and AC output for thousands of problems on uDebug!
Re: 11286 - Conformity, Getting WA, Need Help...
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11286 - Conformity
Input:Output should be 2
Code: Select all
3
100 101 102 103 488
100 101 102 103 488
110 111 200 388 400
0
Check input and AC output for thousands of problems on uDebug!
Re: 11286 - Conformity
thnx brianfry713... ![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)