CodeForces 151B - Phone Numbers

来源:互联网 发布:猎场网络点击量 编辑:程序博客网 时间:2024/06/05 19:10

Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of size si (that's the number of phone numbers). We know that taxi numbers consist of six identical digits (for example, 22-22-22), the numbers of pizza deliveries should necessarily be decreasing sequences of six different digits (for example, 98-73-21), all other numbers are the girls' numbers.

You are given your friends' phone books. Calculate which friend is best to go to when you are interested in each of those things (who has maximal number of phone numbers of each type).

If the phone book of one person contains some number two times, you should count it twice. That is, each number should be taken into consideration the number of times it occurs in the phone book.

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of friends.

Then follow n data blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integer si and string namei (0 ≤ si ≤ 100) — the number of phone numbers in the phone book of the i-th friend and the name of the i-th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from 0 to 9.

Output

In the first line print the phrase "If you want to call a taxi, you should call: ". Then print names of all friends whose phone books contain maximal number of taxi phone numbers.

In the second line print the phrase "If you want to order a pizza, you should call: ". Then print names of all friends who have maximal number of pizza phone numbers.

In the third line print the phrase "If you want to go to a cafe with a wonderful girl, you should call: ". Then print names of all friends who have maximal number of girls' phone numbers.

Print the names in the order in which they are given in the input data. Separate two consecutive names with a comma and a space. Each line should end with exactly one point. For clarifications concerning the output form, see sample tests. It is necessary that youfollow the output form strictly. Extra spaces are not allowed.

Sample test(s)
input
42 Fedorov22-22-2298-76-543 Melnikov75-19-0923-45-6799-99-987 Rogulenko22-22-2211-11-1133-33-3344-44-4455-55-5566-66-6695-43-213 Kaluzhin11-11-1199-99-9998-65-32
output
If you want to call a taxi, you should call: Rogulenko.If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin.If you want to go to a cafe with a wonderful girl, you should call: Melnikov.
input
35 Gleb66-66-6655-55-5501-01-0165-43-2112-34-563 Serega55-55-5587-65-4365-55-215 Melnik12-42-1287-73-0136-04-1288-12-2282-11-43
output
If you want to call a taxi, you should call: Gleb.If you want to order a pizza, you should call: Gleb, Serega.If you want to go to a cafe with a wonderful girl, you should call: Melnik.
input
33 Kulczynski22-22-2265-43-2198-12-004 Pachocki11-11-1111-11-1111-11-1198-76-540 Smietanka
output
If you want to call a taxi, you should call: Pachocki.If you want to order a pizza, you should call: Kulczynski, Pachocki.If you want to go to a cafe with a wonderful girl, you should call: Kulczynski.
代码:
#include <iostream>#include <cstdio>#include <cmath>#include <cstring>#include <algorithm>using namespace std;struct node{    int a,b,c;    int number;    char name[40];}s[110];bool cmp1(node a,node b){    if(a.a!=b.a)        return a.a>b.a;    return a.number<b.number;}bool cmp2(node a,node b){    if(a.b!=b.b)        return a.b>b.b;    return a.number<b.number;}bool cmp3(node a,node b){    if(a.c!=b.c)        return a.c>b.c;    return a.number<b.number;}int main(){    int n;    while(scanf("%d",&n)!=EOF)    {        char ss[40];        int m;        memset(s,0,sizeof(s));        for(int i=0;i<n;i++)        {            scanf("%d%s",&m,s[i].name);            s[i].number=i;            for(int j=0;j<m;j++)            {                scanf("%s",ss);                if(ss[0]==ss[1]&&ss[0]==ss[3]&&ss[3]==ss[4]&&ss[4]==ss[6]&&ss[6]==ss[7])                    s[i].a++;                else if(ss[0]>ss[1]&&ss[1]>ss[3]&&ss[3]>ss[4]&&ss[4]>ss[6]&&ss[6]>ss[7])                    s[i].b++;                else s[i].c++;            }        }        sort(s,s+n,cmp1);        printf("If you want to call a taxi, you should call: %s",s[0].name);        for(int i=1;i<n&&s[i].a==s[i-1].a;i++)             printf(", %s",s[i].name);        printf(".\n");         sort(s,s+n,cmp2);          printf("If you want to order a pizza, you should call: %s",s[0].name);        for(int i=1;i<n&&s[i].b==s[i-1].b;i++)             printf(", %s",s[i].name);        printf(".\n");        sort(s,s+n,cmp3);          printf("If you want to go to a cafe with a wonderful girl, you should call: %s",s[0].name);        for(int i=1;i<n&&s[i].c==s[i-1].c;i++)             printf(", %s",s[i].name);        printf(".\n");    }    return 0;}


原创粉丝点击