Codeforces 151 B struct-body sort.

Source: Internet
Author: User

E- The structure is coming again.Time limit:$ MS Memory Limit:262144KB 64bit IO for Mat:%i64d &%i64u Submit Status Practice codeforces 151B

Description

Winters is just damn freezing cold in nvodsk! That's why a group of n friends prefers-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 have 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 is decreasing sequences of six different digits (for example, 98-73-21), all other numbers is the girls ' numb ERs.

You are given your friends ' phone books. Calculate which friend is the best-go-to-be interested in each of the those things (who have maximal number of phone n Umbers of each type).

If the phone Book of a person contains some number of the times, you should count it twice. That's, each number should being 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 this describe each friend ' s phone books. Each block was presented in the following Form:first goes the line that contains integer  si  and string  namei  (0?≤? s i? ≤?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  - 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 any friends who has maximal number of pizza phone numbers.

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

Print the names in the order in which they is given in the input data. Separate-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's necessary that follow the output form Strictly. Extra spaces is not allowed.

Sample Input

Input
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 the want to order a pizza, you should Call:fedorov, Rogulenko, Kaluzhin.if want to go to a café with a wonderful girl, you should Call:melnikov.
Input
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 the want to order a pizza, you should Call:gleb, serega.if you want To go to a café with a wonderful girl, you should call:melnik.
Input
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 the want to order a pizza, you should Call:kulczynski, Pachocki. If you want to go to a café with a wonderful girl, you should call:kulczynski.

Hint

The

In the first sample is given four friends.   fedorov ' s phone book contains one taxi number and one pizza delivery number,   melnikov ' s phone book only have   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: Rogulenko, Fedorov, Kaluzhin (each of the them has one number). Melnikov has maximal number of phone numbers of girls.

The title of the problem is still relatively good, the requirements of the structure of the grasp is very high. Let's talk about the test instructions.

Look directly at a case.

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 the want to order a pizza, you should Call:fedorov, Rogulenko, Kaluzhin.if want to go to a café with a wonderful girl, you should Call:melnikov.

Look at this case. 4 stands for 4 persons.

Then enter a m and a name.

M on behalf of each person has m phone.

Then there is a rule. The telephone number is equal to the taxi service, the telephone number descending row has the pizza service. The others are girl services.

Then the output is the first taxi, then the pizza, then the girl (the name of the service person). The rule is the output with the most phone number type.

For example, Rogulenko has 6 taxi numbers, others are two, one is not even. So taxis are only Rogulenko.

Look at the pizza output. In addition to Melnikov, everyone has a pizza type of phone (descending number), because at this time everyone has equal, so sequentially output. (who has the name in front of who outputs).

After meeting the above rules. On the code bar.

#include <stdio.h> #include <string.h> #include <algorithm>using namespace std;struct node{int Di,pi,  Girl,haoma; Used to count the number of taxi types, number of pizza type, number of girl type.  Haoma stands for Name Order char name[666];  Name}f[666];bool CMP1 (node A,node b) {if (A.di!=b.di)//per person The number of taxi numbers varies, then return a.di>b.di;  Descending row (because of the large first output) return a.haoma<b.haoma; If equal, output}bool CMP2 (node A,node b) {if (A.PI!=B.PI) return a.pi>b.pi; return a.haoma<b.haoma;//Ibid.}bool Cmp3 ( Node A,node b) {if (a.girl!=b.girl) return A.girl>b.girl;return a.haoma<b.haoma;//Ibid.}int main () {int i,j,n,m;while (~SCANF ("%d", &n))  {char dh[6666];for (i=0;i<n;i++) {scanf ("%d%s", &m,f[i].name); f[i].haoma=i; This is mainly the order of the output names. for (j=0;j<m;j++) {scanf ("%s", DH); if (dh[0]==dh[1]&&dh[0]==dh[3]&&dh[3]==dh[4]&&dh[4]=  =DH[6]&AMP;&AMP;DH[6]==DH[7]) f[i].di++; Satisfy all numbers equal rules, number of taxi type plus one else if (dh[0]>dh[1]&&dh[1]>dh[3]&&dh[3]>dh[4]&&dh[4]  &GT;DH[6]&AMP;&AMP;DH[6]&GT;DH[7]) f[i].pi++; //Meet the number of descending row, the number of pizza type number plus.  elsef[i].girl++;//others are all girl-type numbers}}sort (F,F+N,CMP1);  struct sort printf ("If you want to call a taxi, you should call:%s", f[0].name); The number of the first person must be the most, the direct output for (i=1;i<n&&f[i].di==f[i-1].di;i++)//comparison is the same as the first person, equal words also output.          printf (",%s", f[i].name);  printf (". \ n");   Sort (F,F+N,CMP2);          printf ("If you want to order a pizza, your should call:%s", f[0].name);          for (i=1;i<n&&f[i].pi==f[i-1].pi;i++) printf (",%s", f[i].name);  printf (". \ n");  Ibid. sort (F,f+n,cmp3);          printf ("If you want to go to a café with a wonderful girl, you should call:%s", f[0].name);          for (i=1;i<n&&f[i].girl==f[i-1].girl;i++) printf (",%s", f[i].name);  printf (". \ n"); Ditto} return 0; }


Codeforces 151 B struct-body sort.

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.