01(CodeforcesB水平)CQU新生周末狂欢赛 I - Phone Numbers

I - Phone Numbers
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

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 than20 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 Input

Input
4
2 Fedorov
22-22-22
98-76-54
3 Melnikov
75-19-09
23-45-67
99-99-98
7 Rogulenko
22-22-22
11-11-11
33-33-33
44-44-44
55-55-55
66-66-66
95-43-21
3 Kaluzhin
11-11-11
99-99-99
98-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
3
5 Gleb
66-66-66
55-55-55
01-01-01
65-43-21
12-34-56
3 Serega
55-55-55
87-65-43
65-55-21
5 Melnik
12-42-12
87-73-01
36-04-12
88-12-22
82-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
3
3 Kulczynski
22-22-22
65-43-21
98-12-00
4 Pachocki
11-11-11
11-11-11
11-11-11
98-76-54
0 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.

Hint

In the first sample you are given four friends. Fedorov's phone book contains one taxi number and one pizza delivery number,Melnikov's phone book only has 3 numbers of girls, Rogulenko's one has 6 taxi numbers and one pizza delivery number,Kaluzhin's one contains 2 taxi numbers and one pizza delivery number.

Thus, if you need to order a taxi, you should obviously call Rogulenko, if you need to order a pizza you should call anybody of the following: RogulenkoFedorovKaluzhin (each of them has one number). Melnikov has maximal number of phone numbers of girls.


题意:电话相同为taxi,电话递减为pizza,否则为girl,要什么就找拥有电话数最多的那个人。

思路:先去掉-,然后判断,然后记录,然后输出,做了很久的一道题。

代码:

#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
struct acm{
    string name;
    string number;
    int taxi;
    int pizza;
    int girl;
};

int main()
{
    acm a[110];
    int t,n;
    int maxTaxi = -1,maxGirl = -1,maxPizza = -1;

    cin>>t;
    for(int i=0;i<t;i++){
        a[i].taxi = a[i].pizza = a[i].girl = 0;
        cin>>n>>a[i].name;

        for(int j=0;j<n;j++){
            cin>>a[i].number;

            for(string::iterator iter = a[i].number.begin();iter != a[i].number.end();iter++){
                if(*iter == '-')
                    a[i].number.erase(iter);
            }
            bool taix = true,pizza = true,girl = true;

            for(int k=1;k<a[i].number.size();k++){
                if(a[i].number[k] != a[i].number[k-1]){
                    taix = false;
                }
                if(a[i].number[k]>=a[i].number[k-1]){
                    pizza = false;
                }
            }
            if(taix != false || pizza != false)
                girl = false;
            if(taix == true)a[i].taxi++;
            if(pizza == true)a[i].pizza++;
            if(girl == true)a[i].girl++;
        }
        if(maxTaxi < a[i].taxi)maxTaxi = a[i].taxi;
        if(maxGirl < a[i].girl)maxGirl = a[i].girl;
        if(maxPizza < a[i].pizza)maxPizza = a[i].pizza;
    }
    cout<<"If you want to call a taxi, you should call: ";
        int flag = 0;
        for(int i=0;i<t;i++){
        if(a[i].taxi == maxTaxi)
           flag++;
        }
        for(int i = 0;;i++){
            if(a[i].taxi == maxTaxi){
                if(flag != 1){
                cout<<a[i].name<<", ";
                flag--;
                }
                else{
                    cout<<a[i].name<<"."<<endl;
                    break;
                }
            }
    }

flag = 0;
     cout<<"If you want to order a pizza, you should call: ";
     for(int i=0;i<t;i++){
     if(a[i].pizza == maxPizza)
        flag++;
     }
     for(int i = 0;;i++){
         if(a[i].pizza == maxPizza){
             if(flag != 1){
             cout<<a[i].name<<", ";
             flag--;
             }
             else{
                 cout<<a[i].name<<"."<<endl;
                 break;
             }
         }
 }
     flag = 0;
      cout<<"If you want to go to a cafe with a wonderful girl, you should call: ";
      for(int i=0;i<t;i++){
      if(a[i].girl == maxGirl)
         flag++;
      }
      for(int i = 0;;i++){
          if(a[i].girl == maxGirl){
              if(flag != 1){
              cout<<a[i].name<<", ";
              flag--;
              }
              else{
                  cout<<a[i].name<<"."<<endl;
                  break;
              }
          }
  }

    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值