Start: Dec, 04, 2016 12:00:00
杭州师范大学第十届程序设计竞赛—正式
End: Dec, 04, 2016 17:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 0ms
Memory: 1096kB
In contest: 1075

#include<stdio.h>
#include<stdlib.h>
struct fri
{
	char name[100];
	int key=0;
	int game=0;
	int cafe=0;
	int paixu;
};
int comp1(const void *p,const void *q)
{
	return ((struct fri *)q)->key-((struct fri *)p)->key;
}
int comp2(const void *p,const void *q)
{
	return ((struct fri *)q)->game-((struct fri *)p)->game;
}
int comp3(const void *p,const void *q)
{
	return ((struct fri *)q)->cafe-((struct fri *)p)->cafe;
}
int comp4(const void *p,const void *q)
{
	return ((struct fri *)p)->paixu-((struct fri *)q)->paixu;
}
int main()
{
	int n,m,d,max;
	char c[10];
	struct fri a[1000];
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d %s",&n,a[i].name);
		a[i].paixu=i;
		for(int j=0;j<n;j++)
		{
			scanf("%s",c);
			if(c[0]==c[1]&&c[1]==c[3]&&c[3]==c[4]&&c[4]==c[6]&&c[6]==c[7])
			{
				a[i].key+=1;
			}
			else if(c[0]>c[1]&&c[1]>c[3]&&c[3]>c[4]&&c[4]>c[6]&&c[6]>c[7])
			{
				a[i].game+=1;
			}
			else
			a[i].cafe+=1;
		}
   }
   qsort(a,m,sizeof(struct fri),comp1);
   max=a[0].key;
   d=0;
    for(int i=0;i<m;i++)
   {
   	if(a[i].key==max)
   	d++;
   }
   printf("If you want to have a keyboard, you should call: ");
   if(d==1)
    printf("%s.\n",a[0].name);
    else{
    	qsort(a,m,sizeof(struct fri),comp4);
   for(int i=0;i<m;i++)
   {
   	if(max==a[i].key){
   	printf("%s",a[i].name);
   	if(d!=1){
   	printf(", ");d-=1;}
   	else
   	printf(".\n");}
   }}
   
    qsort(a,m,sizeof(struct fri),comp2);
   max=a[0].game;
   d=0;
    for(int i=0;i<m;i++)
   {
   	if(a[i].game==max)
   	d++;
   }
   printf("If you want to order a Watchdog2, you should call: ");
      if(d==1)
    printf("%s.\n",a[0].name);
   else{
    	qsort(a,m,sizeof(struct fri),comp4);
   for(int i=0;i<m;i++)
   {
   	if(max==a[i].game){
   	printf("%s",a[i].name);
   	if(d!=1){
   	printf(", ");d-=1;}
   	else
   	printf(".\n");}
   }}
   
   qsort(a,m,sizeof(struct fri),comp3);
   max=a[0].cafe;
   d=0;
    for(int i=0;i<m;i++)
   {
   	if(a[i].cafe==max)
   	d++;
   }
   printf("If you want to have a cup of coffee with a girl, you should call: ");
      if(d==1)
    printf("%s.\n",a[0].name);
    else{
    	qsort(a,m,sizeof(struct fri),comp4);
   for(int i=0;i<m;i++)
   {
   	if(max==a[i].cafe){
   	printf("%s",a[i].name);
   	if(d!=1){
   	printf(", ");d-=1;}
   	else
   	printf(".\n");}
   }}}