CodeForces 151B Phone Numbers(简单模拟)
来源:互联网 发布:pps网络电视播放器 编辑:程序博客网 时间:2024/06/04 00:40
题目链接
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 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 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 ittwice. That is, each number should be taken into consideration the number of times it occurs in the phone book.
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 integersi and stringnamei (0 ≤ si ≤ 100) — the number of phone numbers in the phone book of thei-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 than20 characters. Next si lines contain numbers as "XX-XX-XX", where X is arbitrary digits from0 to 9.
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;}
- CodeForces 151B Phone Numbers(简单模拟)
- CodeForces 151B - Phone Numbers
- CodeForces 151B - Phone Numbers
- 【codeforces#25B】 Phone numbers
- B. Phone Numbers
- B. Phone numbers
- codeforces 74B Train 贪心 简单模拟
- CodeForces 697 B. Barnicle(简单模拟)
- 简单模拟 CodeForces - 404B Marathon
- codeforces-626-B. Cards(简单模拟)
- codeforces 898C. Phone Numbers
- Codeforces 213B Numbers
- CodeForces 25BPhone numbers(简单的字符串模拟题目)
- codeforces Round #451 (Div. 2) Phone Numbers
- Codeforces Round #107 (Div. 2) B (简单模拟)
- CodeForces 567B Berland National Library(模拟)(简单)
- CodeForces 680B Bear and Finding Criminals 简单模拟
- CodeForces - 451B Sort the Array 简单模拟
- 单片机程序员的面试
- C++实现模式--单例
- 服务端技术选型
- 深入理解JNI
- bzoj-1503 郁闷的出纳员
- CodeForces 151B Phone Numbers(简单模拟)
- D3D变换的理解
- 模拟按钮控件BN_CLICKED消息事件
- leetcode--Best Time to Buy and Sell Stock i ii iii
- KVC操作key路径
- 面试题:数组有没有length()方法? 字符串有没有length()方法? 集合有没有length()方法?
- AlertDialog加入布局文件
- Cache优化
- 刷牙讲究的方法