CodeForces 151 B struct sorting.

Source: Internet
Author: User

CodeForces 151 B struct sorting.
The E-struct is coming again.Time Limit:2000 MSMemory Limit:262144KB64bit IO Format:% I64d & % I64uSubmit Status Practice CodeForces 151B

Description

Winters are just damn freezing cold in Nvodsk! That's why a groupNFriends 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 sizeSI(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 showould 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 shocould count it twice. That is, each number shocould be taken into consideration the number of times it occurs in the phone book.

Input

The first line contains an integerN(1? ≤?N? ≤? 100)-the number of friends.

Then followNData blocks that describe each friend's phone books. Each block is presented in the following form: first goes the line that contains integerSIAnd stringNameI(0? ≤?SI? ≤? 100)-the number of phone numbers in the phone book ofI-Th friend and the name ofI-Th friend. The name is a non-empty sequence of uppercase and lowercase Latin letters, containing no more than 20 characters. NextSILines 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 showould 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 showould 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 shoshould 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 shoshould end with exactly one point. for clarifications concerning the output form, see sample tests. it is necessary that you follow the output form strictly. extra spaces are not allowed.

Sample Input

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.

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 shoshould obviusly call Rogulenko, if you need to order a pizza you shoshould call anybody of the following: Rogulenko, Fedorov, kaluzhin (each of them has one number ). melnikov has maximal number of phone numbers of girls.

This question is still relatively good and requires a high level of understanding the structure. Let's talk about the question first.

Let's look at a case.

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.

Let's look at this case. 4 represents four people.

Enter M and a name.

M indicates that each person has M calls.

Then there is a rule. There are taxi services and pizza services in descending order of telephone numbers. Other services are GIRL services.

The output is the first taxi, then the pizza, and then the girl (the name of the Service person ). The rule is the output with the most phone number types.

For example, Rogulenko has six taxi numbers, and the other team has two or even none. So the taxi is only Rogulenko.

View the output of the pizza. Except Melnikov, each person has a pizza-type phone number (descending order number), because at this time each person has an equal, so output in order. (Who has the name output first ).

After the above rules are met. On the code.

# Include
 
  
# Include
  
   
# Include using namespace std; struct node {int di, pi, girl, haoma; // Number of the taxi type, number of the pizza type, and number of the girl type. Haoma indicates the sequential name char name [666]; // name} f [666]; bool cmp1 (node a, node B) {if (a. di! = B. di) // return a. di> B. di if the number of each person's taxi number is different; // descending order (because of the large first output) return a. haoma
   
    
B. pi; return a. haoma
    
     
B. girl; return a. haoma
     
      
Dh [1] & dh [1]> dh [3] & dh [3]> dh [4] & dh [4]> dh [6] & dh [6]> dh [7]) f [I]. pi ++; // The number that meets the descending order. The number of pizza numbers is added. Elsef [I]. girl ++; // other all girl-type numbers} sort (f, f + n, cmp1); // structure sorting printf ("If you want to call a taxi, you shoshould call: % s ", f [0]. name); // The number of the first person must be the largest, and The for (I = 1; I
      
       


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.