Result: Accepted
Time: 1ms
Memory: 1096kB
#include<stdio.h>
#include<string.h>
int main()
{
int t;
int i,j,n,k;
char name[101][21],num[101][9];
scanf("%d",&t);
k=t;
int a[101][3]={0};
while(t--)
{
scanf("%d %s",&n,name[t]);
getchar();
for(i=0;i<n;++i)
{
scanf("%s",&num[i]);
for(j=0;j<7;++j)
{
if(j==2||j==5)
continue;
if(j==0||j==3||j==6)
if(num[i][j]!=num[i][j+1])
break;
if(j==1||j==4)
if(num[i][j]!=num[i][j+2])
break;
}
if(j==7)
{
a[t][0]++;
continue;
}
for(j=0;j<7;++j)
{
if(j==2||j==5)
continue;
if(j==0||j==3||j==6)
if(num[i][j]<=num[i][j+1])
break;
if(j==1||j==4)
if(num[i][j]<=num[i][j+2])
break;
}
if(j==7)
{
a[t][1]++;
}
else
a[t][2]++;
}
}
int max=0;
int p=0;
for(i=0;i<k;++i)
{
if(a[i][0]>max)
max = a[i][0];
}
printf("If you want to have a keyboard, you should call:");
for(i=k-1;i>=0;i--)
{
if(a[i][0]==max&&p==0)
{
printf(" %s",name[i]);
p++;
continue;
}
if(a[i][0]==max&&p!=0)
printf(", %s",name[i]);
}
printf(".\n");
max = 0;
p=0;
for(i=0;i<k;++i)
{
if(a[i][1]>max)
max = a[i][1];
}
printf("If you want to order a Watchdog2, you should call:");
for(i=k-1;i>=0;i--)
{
if(a[i][1]==max&&p==0)
{
printf(" %s",name[i]);
p++;
continue;
}
if(a[i][1]==max&&p!=0)
printf(", %s",name[i]);
}
printf(".\n");
max=0;
p=0;
for(i=0;i<k;++i)
{
if(a[i][2]>max)
max = a[i][2];
}
printf("If you want to have a cup of coffee with a girl, you should call:");
for(i=k-1;i>=0;i--)
{
if(a[i][2]==max&&p==0)
{
printf(" %s",name[i]);
p++;
continue;
}
if(a[i][2]==max&&p!=0)
printf(", %s",name[i]);
}
printf(".\n");
return 0;
}