Result: Accepted
Time: 1ms
Memory: 2292kB
#include<stdio.h>
#include<string.h>
struct name{
char str[110][110];
char na[30];
int num1,num2,num3,num,flag;
}p[101];
int main()
{
int t,i,j,a[101],b[101],c[101];
scanf("%d",&t);
for(i=0;i<t;++i)
{
scanf("%d%s",&p[i].num,p[i].na);
p[i].num1 = p[i].num2 = p[i].num3 = 0;
for(j=0;j<p[i].num;j++)
{
int k,temp=-1,key=1,key2=1;
scanf("%s",p[i].str[j]);
for(k=0;k<8;++k)
{
if(k==2||k==5)
continue;
else
{
if(temp==-1)
temp = p[i].str[j][k]-'0';
else if(temp != p[i].str[j][k]-'0')
{
key = 0;
break;
}
}
}
if(key)
p[i].num1++;//same
//printf("%d\n",key);
temp=-1;
for(k=0;k<8;++k)
{
if(k==2||k==5)
continue;
else if(temp == -1)
temp = p[i].str[j][k]-'0';
else if(temp > p[i].str[j][k]-'0')
temp = p[i].str[j][k]-'0';
else
{
key2 = 0;
break;
}
}
if(key2)
p[i].num2++;//small
//printf("%d\n",key2);
if(key==0&&key2==0)
p[i].num3++;
}
}
int temp1,temp2 ,temp3=0,n1=0,n2=0,n3=0;
temp1 = temp2=0;
for(i=0;i<t;i++)
{
if(p[i].num1>temp1)
temp1 = p[i].num1;
if(p[i].num2>temp2)
temp2 = p[i].num2;
if(p[i].num3>temp3)
temp3 = p[i].num3;
}
for(i=0;i<t;i++)
{
if(p[i].num1==temp1)
n1++;
if(p[i].num2==temp2)
n2++;
if(p[i].num3==temp3)
n3++;
}
//printf("%d\n",p[0].str[0][1]-'0');
printf("If you want to have a keyboard, you should call: ");
for(i=0;i<t;i++)
{
if(p[i].num1==temp1)
{
n1--;
if(n1)
printf("%s, ",p[i].na);
else
printf("%s.\n",p[i].na);
}
}
printf("If you want to order a Watchdog2, you should call: ");
for(i=0;i<t;i++)
{
if(p[i].num2==temp2)
{
n2--;
if(n2)
printf("%s, ",p[i].na);
else
printf("%s.\n",p[i].na);
}
}
printf("If you want to have a cup of coffee with a girl, you should call: ");
for(i=0;i<t;i++)
{
if(p[i].num3==temp3)
{
n3--;
if(n3)
printf("%s, ",p[i].na);
else
printf("%s.\n",p[i].na);
}
}
}