Result: Accepted
Time: 1ms
Memory: 1704kB
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
struct student
{
string name;
int key;
int dog;
int girl;
};
int main()
{
student kaohao[100];
int t;
cin>>t;
int cou=t;
int a,b,c;
char d,e;
int n;
string na;
//t++;
int i=0;
while(t--)
{
scanf("%d",&n);
cin>>na;
kaohao[i].name=na;
kaohao[i].dog=0;
kaohao[i].girl=0;
kaohao[i].key=0;
while(n--)
{
cin>>a>>d>>b>>e>>c;
if(a==b&&b==c)
{
kaohao[i].key++;
//continue;
}
if((a/10>a%10)&&(a%10>b/10)&&(b/10>b%10)&&(b%10>c/10)&&(c/10>c%10))
{
kaohao[i].dog++;
//continue;
}
kaohao[i].girl++;
}
kaohao[i].girl=kaohao[i].girl-kaohao[i].dog-kaohao[i].key;
i++;
}
string x,y,z;
int max=0;
int k=0;
int l=0;
for(int i=0;i<cou;++i)
{
if(kaohao[i].key>max)
{
max=kaohao[i].key;
}
}
for(int i=0;i<cou;++i)
if(kaohao[i].key==max)
k++;
printf("If you want to have a keyboard, you should call:");
for(int i=0;i<cou;++i)
{
if(kaohao[i].key==max&&l==k-1)
{
cout<<' '<<kaohao[i].name<<'.'<<endl;
l++;
}
if(kaohao[i].key==max&&l<k-1)
{
cout<<' '<<kaohao[i].name<<',';
l++;
}
}
k=0;
l=0;
max=0;
for(int i=0;i<cou;++i)
{
if(kaohao[i].dog>max)
{
max=kaohao[i].dog;
}
}
for(int i=0;i<cou;++i)
if(kaohao[i].dog==max)
k++;
printf("If you want to order a Watchdog2, you should call:");
for(int i=0;i<cou;++i)
{
if(kaohao[i].dog==max&&l==k-1)
{
cout<<' '<<kaohao[i].name<<'.'<<endl;
l++;
}
if(kaohao[i].dog==max&&l<k-1)
{
cout<<' '<<kaohao[i].name<<',';
l++;
}
}
k=0;
max=0;
l=0;
for(int i=0;i<cou;++i)
{
if(kaohao[i].girl>max)
{
max=kaohao[i].girl;
//k++;
}
}
for(int i=0;i<cou;++i)
if(kaohao[i].girl==max)
k++;
printf("If you want to have a cup of coffee with a girl, you should call:");
for(int i=0;i<cou;++i)
{
if(kaohao[i].girl==max&&l==k-1)
{
cout<<' '<<kaohao[i].name<<'.'<<endl;
l++;
}
if(kaohao[i].girl==max&&l<k-1)
{
cout<<' '<<kaohao[i].name<<',';
l++;
}
}
//cout<<"11\n";
return 0;
}