CodeForces 151B Phone Numbers(简单模拟)

题目链接

B. Phone Numbers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

题解:简单模拟

代码如下:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<string.h>
#include<string>
#include<stdlib.h>
typedef __int64 LL;
typedef unsigned __int64 LLU;
const int nn=1100;
const int inf=0x3fffffff;
const LL inf64=(LL)inf*inf;
using namespace std;
int n;
struct node
{
    string name;
    int val[3];
}a[nn];
int b[10];
bool checkt(string s)
{
    int i;
    int ls=s.size();
    for(i=0;i<ls;i++)
    {
        if(s[i]!='-')
        {
            if(s[i]==s[0])
                continue;
            else
                return false;
        }
    }
    return true;
}
bool checkp(string s)
{
    int i;
    int ls=s.size();
    int pre=0;
    for(i=1;i<ls;i++)
    {
        if(s[i]!='-')
        {
            if(s[i]<s[pre])
            {
                pre=i;
                continue;
            }
            else
                return false;
        }
    }
    return true;
}
vector<string>ve[3];
int ans[3];
int main()
{
    int i,j;
    char s[50];
    while(scanf("%d",&n)!=EOF)
    {
        int si;
        ans[0]=ans[1]=ans[2]=0;
        for(i=1;i<=n;i++)
        {
            scanf("%d%s",&si,s);
            a[i].name=s;
            for(j=0;j<3;j++)
            {
                a[i].val[j]=0;
            }
            for(j=0;j<si;j++)
            {
                scanf("%s",s);
                if(checkt(s))
                {
                    a[i].val[0]++;
                }
                else if(checkp(s))
                {
                    a[i].val[1]++;
                }
                else
                    a[i].val[2]++;
            }
            for(j=0;j<3;j++)
            {
                if(a[i].val[j]>ans[j])
                {
                    ans[j]=a[i].val[j];
                    ve[j].clear();
                    ve[j].push_back(a[i].name);
                }
                else if(a[i].val[j]==ans[j])
                {
                    ve[j].push_back(a[i].name);
                }
            }
        }
        printf("If you want to call a taxi, you should call:");
        int lv=ve[0].size();
        for(i=0;i<lv;i++)
        {
            cout<<" "<<ve[0][i];
            printf("%c",i==lv-1?'.':',');
        }
        puts("");
        printf("If you want to order a pizza, you should call:");
        lv=ve[1].size();
        for(i=0;i<lv;i++)
        {
            cout<<" "<<ve[1][i];
            printf("%c",i==lv-1?'.':',');
        }
        puts("");
        printf("If you want to go to a cafe with a wonderful girl, you should call:");
        lv=ve[2].size();
        for(i=0;i<lv;i++)
        {
            cout<<" "<<ve[2][i];
            printf("%c",i==lv-1?'.':',');
        }
        puts("");
    }
    return 0;
}


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值