CodeForces 151B Phone Numbers

Phone Numbers

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

Submit Status Practice CodeForces 151B

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 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 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 2taxi 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 them has one number). Melnikov has maximal number of phone numbers of girls.

  1 #include <stdio.h>
  2 #include <string.h>
  3
  4 int main()
  5 {
  6     int n,s;
  7     int i,j,k,l,tma,pma,gma;
  8     int a[10]={0,0,1,3,4,6,7};
  9     int nub[105][5];
 10     char nam[105][56],tel[10];
 11     while(scanf("%d",&n)!=EOF)
 12     {
 13         memset(nub,0,sizeof(nub));
 14         tma=0,pma=0,gma=0;
 15         for(l=1;l<=n;l++)
 16         {
 17             scanf("%d",&s);
 18             scanf("%s",nam[l]);
 19             for(k=1;k<=s;k++)
 20             {
 21                 int fa=1;
 22                 scanf("%s",tel);
 23                 for(i=2;i<=6;i++)
 24                 {
 25                     if(tel[a[i]]>=tel[a[i-1]])
 26                     {
 27                         fa=0;
 28                         break;
 29                     }
 30                 }
 31                 if(tel[0]==tel[1] && tel[0]==tel[3]  && tel[0]==tel[4] && tel[0]==tel[6] && tel[0]==tel[7])
 32                 {
 33                     nub[l][1]++;
 34                 }
 35                 else if(fa==1)
 36                 {
 37                     nub[l][2]++;
 38                 }
 39                 else
 40                 {
 41                     nub[l][3]++;
 42                 }
 43             }
 44             if(nub[l][1]>tma)
 45                 tma=nub[l][1];
 46             if(nub[l][2]>pma)
 47                 pma=nub[l][2];
 48             if(nub[l][3]>gma)
 49                 gma=nub[l][3];
 50         }
 51         printf("If you want to call a taxi, you should call:");
 52         int flg=1;
 53         for(i=1;i<=n;i++)
 54         {
 55             if(nub[i][1]==tma)
 56             {
 57                 if(flg==1)
 58                 {
 59                     printf(" %s",nam[i]);
 60                     flg=0;
 61                 }
 62                 else
 63                 {
 64                     printf(", %s",nam[i]);
 65                 }
 66             }
 67         }
 68         printf(".\n");
 69
 70         printf("If you want to order a pizza, you should call:");
 71         flg=1;
 72         for(i=1;i<=n;i++)
 73         {
 74             if(nub[i][2]==pma)
 75             {
 76                 if(flg==1)
 77                 {
 78                     printf(" %s",nam[i]);
 79                     flg=0;
 80                 }
 81                 else
 82                 {
 83                     printf(", %s",nam[i]);
 84                 }
 85             }
 86         }
 87         printf(".\n");
 88
 89         printf("If you want to go to a cafe with a wonderful girl, you should call:");
 90         flg=1;
 91         for(i=1;i<=n;i++)
 92         {
 93             if(nub[i][3]==gma)
 94             {
 95                 if(flg==1)
 96                 {
 97                     printf(" %s",nam[i]);
 98                     flg=0;
 99                 }
100                 else
101                 {
102                     printf(", %s",nam[i]);
103                 }
104             }
105         }
106         printf(".\n");
107     }return 0;
108 }

时间: 2024-10-13 15:51:34

CodeForces 151B Phone Numbers的相关文章

codeforces 165E - Compatible Numbers 【位运算】

题目:codeforces 165E - Compatible Numbers 题意:给出n个数,然后每个数对应输出一个当前数组中与 Ai 与运算为 0 的数,没有的话输出-1 分析:简单的位运算题目,技巧性题目 首先,我们知道与运算的性质,就是只有同时为 1的时候才是1,那么假如 x&y=0 ,就是至少 x 的为1的为 y 全为0,其他为自由,假设为 1 ,那么 y = x^((1<<22)-1).但是这样并不是全部的,这些位还可能是0,所以我们可以枚举这些位,然后处理. 具体看代码

codeforces 509D Restoring Numbers

codeforces 509D Restoring Numbers 题意: v[i][j]=(a[i]+b[j])%k 现在给出n*m矩阵v[][], 求a[],b[]和k, 任意一种情况都行. 限制: 1 <= n,m <= 100; 0 <= v[i][j] <= 100 思路: 对于数组a[], 无论怎么变, 数组之间的差始终不变, b[]也同理 利用这个求出k 再设a[0]=0,b[0]=0,求出剩下的东西.

CodeForces 55D Beautiful numbers 数位DP+数学

题意大概是,判断一个正整数区间内有多少个整数能被它自身的每一个非零的数字整除. 因为每一个位置上的整数集s = {0,1,2,3,4,5,6,7,8,9} lcm(s) = 2520 现在有一个整数t是由s中一个或者多个数字构成的,记为abcde,显然t = a*10^4+b*10^3+c*10^2+d*10^1+e 要使得t能被a,b,c,d,e整除,必然有t % lcm(a,b,c,d,e) = 0 因为a,b,c,d,e去重之后一定是s的一个子集,所以lcm(s)一定是lcm(a,b,c,

Codeforces 55D. Beautiful numbers(数位DP,离散化)

Codeforces 55D. Beautiful numbers 题意 求[L,R]区间内有多少个数满足:该数能被其每一位数字都整除(如12,24,15等). 思路 一开始以为是数位DP的水题,觉得只需要记录搜到当前位出现了哪些数字作为状态即可,明显是假算法...感觉这是一道数位DP好题.可以这样思考:一个数要想被其各位数字分别都整除,等价于它被那些数字的LCM整除.因此记录当前位,当前数对(1~9的LCM)取模的结果,当前出现的数字的LCM这三个值作为状态才合理,即dp[pos][sum][

codeforces Gym 100338E Numbers

题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include<bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int maxbit = 19; ull base[maxbit], n, k; void preDeal() { base[0] = 1; for(in

CodeForces E. Binary Numbers AND Sum

http://codeforces.com/contest/1066/problem/E You are given two huge binary integer numbers aa and bb of lengths nn and mm respectively. You will repeat the following process: if b>0b>0, then add to the answer the value a & ba & b and divide 

CodeForces 55D Beautiful numbers(数位dp&amp;&amp;离散化)

题目链接:[kuangbin带你飞]专题十五 数位DP A - Beautiful numbers 题意 ps:第一道数位dp,题真好,虽然是参考大牛方法悟过才a,但仍收获不少. 求一个区间内的Beautiful numbers有多少个.Beautiful numbers指:一个数能整除所有组成它的非0数字. 例如15可以被1和5整除,所以15是Beautiful numbers. 思路 Beautiful numbers指:一个数能整除所有组成它的非0数字. 等同于 一个数能整除 所有组成它的

CodeForces 55D Beautiful numbers

Beautiful numbers 题目链接 Description Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just

CodeForces 300C Beautiful Numbers(乘法逆元/费马小定理+组合数公式+快速幂)

C. Beautiful Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal