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

Problem_ID: D
Result: Accepted
Time: 1ms
Memory: 2236kB
In contest: 1075

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
using namespace std;
struct f{
	int num;   
	string name;
	string tel[200];
	int keyboard;
	int Watchdog2;
	int coffee;
	int flag;
	int no;
};
int comp1(const void *p,const void *q){
	return ((struct f *)q)->keyboard-((struct f *)p)->keyboard;
}
int comp2(const void *p,const void *q){
	return ((struct f *)q)->Watchdog2-((struct f *)p)->Watchdog2;
}
int comp3(const void *p,const void *q){
	return ((struct f *)q)->coffee-((struct f *)p)->coffee;
}
int main(){
	int n;            //代表有n个朋友 
	scanf("%d",&n);
	struct f fri[100];
	struct f fri1[100];
	struct f fri2[100];
	struct f fri3[100];
	int i,j;
	for(i=0;i<n;++i){ 
	    fri[i].no=i;
		scanf("%d",&fri[i].num);
		getchar(); 
		getline(cin,fri[i].name);
	    for(j=0;j<fri[i].num;++j){
	       getline(cin,fri[i].tel[j]);
	    } 
	    fri[i].keyboard=0;
	    fri[i].Watchdog2=0;
	    fri[i].coffee=0;
		for(j=0;j<fri[i].num;++j){
	    	if(fri[i].tel[j][0]==fri[i].tel[j][1]&&fri[i].tel[j][1]==fri[i].tel[j][3]&&fri[i].tel[j][3]==fri[i].tel[j][4]&&fri[i].tel[j][4]==fri[i].tel[j][6]&&fri[i].tel[j][6]==fri[i].tel[j][7]){
			   fri[i].keyboard++;
			}
	    	else if(((fri[i].tel[j][0]-'0')>(fri[i].tel[j][1]-'0'))&&((fri[i].tel[j][1]-'0')>(fri[i].tel[j][3]-'0'))&&((fri[i].tel[j][3]-'0')>(fri[i].tel[j][4]-'0'))&&((fri[i].tel[j][4]-'0')>(fri[i].tel[j][6]-'0'))&&((fri[i].tel[j][6]-'0')>(fri[i].tel[j][7]-'0'))){
		       fri[i].Watchdog2++;
			}
	    	else
	    	   fri[i].coffee++;
		}
	}
	for(i=0;i<n;++i)
	  fri1[i]=fri[i];
	for(i=0;i<n;++i)
	  fri2[i]=fri[i];
	for(i=0;i<n;++i)
	  fri3[i]=fri[i];
	int num[1000];
	int count1=1,count2=1,count3=1;
	for(i=0;i<n;++i)
	  num[i]=0;
	qsort(fri1,n,sizeof(struct f),comp1);
	num[fri1[0].no]=1;
	for(i=1;i<n;++i){
		if(fri1[i].keyboard==fri1[0].keyboard){
	        num[fri1[i].no]=1;
	        count1++;
	    }
	}
	cout<<"If you want to have a keyboard, you should call:";
	for(i=0;i<n;++i){
		if(num[i]==1){
		  cout<<" "<<fri[i].name;
		  count1--;
		  if(count1>0)
	      cout<<",";
	      else
	      cout<<"."<<endl;
	    }
	}
	for(i=0;i<n;++i)
	  num[i]=0;
	qsort(fri2,n,sizeof(struct f),comp2);
	num[fri2[0].no]=1;
	for(i=1;i<n;++i){
		if(fri2[i].Watchdog2==fri2[0].Watchdog2){
	        num[fri2[i].no]=1;
	        count2++;
	    }
	}
	cout<<"If you want to order a Watchdog2, you should call:";
	for(i=0;i<n;++i){
		if(num[i]==1){
		  cout<<" "<<fri[i].name;
		  count2--;
		  if(count2>0)
	        cout<<",";
	      else
	        cout<<"."<<endl;
	    }
	}
	for(i=0;i<n;++i)
	  num[i]=0;
	qsort(fri3,n,sizeof(struct f),comp3);
	num[fri3[0].no]=1;
	for(i=1;i<n;++i){
		if(fri3[i].coffee==fri3[0].coffee){
	        num[fri[i].no]=1;
	        count3++;
	    }
	}
	cout<<"If you want to have a cup of coffee with a girl, you should call:";
	for(i=0;i<n;++i){
		if(num[i]==1){
		  cout<<" "<<fri[i].name;
		  count3--;
		  if(count3>0)
	      cout<<",";
	      else
	      cout<<"."<<endl;
	    }
	}
	return 0;
}