CodeForces 151B 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 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
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
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.
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
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.
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
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.
#include <stdio.h>
#include <string.h> int main()
{
int n,s;
int i,j,k,l,tma,pma,gma;
int a[]={,,,,,,};
int nub[][];
char nam[][],tel[];
while(scanf("%d",&n)!=EOF)
{
memset(nub,,sizeof(nub));
tma=,pma=,gma=;
for(l=;l<=n;l++)
{
scanf("%d",&s);
scanf("%s",nam[l]);
for(k=;k<=s;k++)
{
int fa=;
scanf("%s",tel);
for(i=;i<=;i++)
{
if(tel[a[i]]>=tel[a[i-]])
{
fa=;
break;
}
}
if(tel[]==tel[] && tel[]==tel[] && tel[]==tel[] && tel[]==tel[] && tel[]==tel[])
{
nub[l][]++;
}
else if(fa==)
{
nub[l][]++;
}
else
{
nub[l][]++;
}
}
if(nub[l][]>tma)
tma=nub[l][];
if(nub[l][]>pma)
pma=nub[l][];
if(nub[l][]>gma)
gma=nub[l][];
}
printf("If you want to call a taxi, you should call:");
int flg=;
for(i=;i<=n;i++)
{
if(nub[i][]==tma)
{
if(flg==)
{
printf(" %s",nam[i]);
flg=;
}
else
{
printf(", %s",nam[i]);
}
}
}
printf(".\n"); printf("If you want to order a pizza, you should call:");
flg=;
for(i=;i<=n;i++)
{
if(nub[i][]==pma)
{
if(flg==)
{
printf(" %s",nam[i]);
flg=;
}
else
{
printf(", %s",nam[i]);
}
}
}
printf(".\n"); printf("If you want to go to a cafe with a wonderful girl, you should call:");
flg=;
for(i=;i<=n;i++)
{
if(nub[i][]==gma)
{
if(flg==)
{
printf(" %s",nam[i]);
flg=;
}
else
{
printf(", %s",nam[i]);
}
}
}
printf(".\n");
}return ;
}
CodeForces 151B Phone Numbers的更多相关文章
- CodeForces 55D "Beautiful numbers"(数位DP+离散化处理)
传送门 参考资料: [1]:CodeForces 55D Beautiful numbers(数位dp&&离散化) 我的理解: 起初,我先定义一个三维数组 dp[ i ][ j ][ ...
- Codeforces 878 E. Numbers on the blackboard
Codeforces 878 E. Numbers on the blackboard 解题思路 有一种最优策略是每次选择最后面一个大于等于 \(0\) 的元素进行合并,这样做完以后相当于给这个元素乘 ...
- Codeforces 55D. Beautiful numbers(数位DP,离散化)
Codeforces 55D. Beautiful numbers 题意 求[L,R]区间内有多少个数满足:该数能被其每一位数字都整除(如12,24,15等). 思路 一开始以为是数位DP的水题,觉得 ...
- codeforces 55D - Beautiful numbers(数位DP+离散化)
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...
- Codeforces 165E Compatible Numbers(二进制+逆序枚举)
E. Compatible Numbers time limit per test 4 seconds memory limit per test 256 megabytes input standa ...
- codeforces Gym 100338E Numbers (贪心,实现)
题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include< ...
- CodeForces 165E Compatible Numbers(位运算 + 好题)
wo integers x and y are compatible, if the result of their bitwise "AND" equals zero, that ...
- CodeForces 55D Beautiful numbers
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...
- codeforces 630C Lucky Numbers
C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard i ...
随机推荐
- 创建本地yum软件源,为本地Package安装Cloudera Manager、Cloudera Hadoop及Impala做准备
一.包管理工具及CentOS的yum 1.包管理工具如何发现可以用的包 包管理工具依赖一系列软件源,工具下载源的信息存储在配置文件中,其位置随某包管理工具不同而变化 使用yum的RedHat/Cent ...
- 一、Java基础--01
Java基础测试题分析 第一题是关于基本的算法知识,这个很有必要去掌握以下,在学校也经常听老师们说找工作比试面试会出一些这方面的知识,我拿到的第一题是关于排序的,虽然很简单,但是我还是要提醒一下基础不 ...
- Entity Framework 无法对没有主键的视图映射实体的解决办法
我们在使用Entity Framework的时候经常会把数据库中的某一个视图映射为EF的实体,但是如果数据库视图中的列没有包含表的主键列,EF会报出警告说视图没有主键,导致视图映射为实体失败,错误如下 ...
- 赤手空拳编写C#代码
有时候服务器上并没有安装任何IDE或典型的代码编辑器,只能完全手写C#代码. 不妨假设一台全新的PC,较新版本的Windows自带了.net框架,无需开发工具即可编程了. 除了以往的Bat批处理.VB ...
- COM编程概述
所谓COM,英文为Componet Object Model,中文为组件对象模型(其实这种解释只有在考试卷上才具有一点实际意义). [1]为什么需要COM? COM是为了解决OLE问题而产生的.COM ...
- android 学习随笔二十九(自定义监听 )
package com.itheima.momo.dialog; import com.itheima.momo.R; import android.app.AlertDialog; import a ...
- netsh修改IP及DNS
netsh interface ip show addresses 显示当前IP netsh interface ip show dns 显示当前DNS netsh interf ...
- Git 使用规范流程
Git教程:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 团队开发中,遵循一个合 ...
- Content Delivery Network
Coding Standards & Best Practices 7 Reasons to use a Content Delivery Network CDN公共库汇总
- 【jQuery UI 1.8 The User Interface Library for jQuery】.学习笔记.5.Accordion控件
accordion是另一个UI控件,能允许你将一组content加入相互分隔的.能够被浏览者的交互打开或关闭的panels中.因此,它大多数的content在初始化的时候是隐藏的,很像tabs控件.每 ...