[CF151B]Phone Numbers(暴力,模拟)
题目链接:http://codeforces.com/contest/151/problem/B
题意:三种电话号码:假如数字都相同,则说明是taxi;严格下降的序列则说明是pizza;其他是girl。输出拥有某种号码最多的那个人的姓名,假如有同样多的,要按照输入顺序输出。
暴力搞,统计每个人各种电话号码有多少,排序三遍。
1 /* 2 ━━━━━┒ギリギリ♂ eye! 3 ┓┏┓┏┓┃キリキリ♂ mind! 4 ┛┗┛┗┛┃\○/ 5 ┓┏┓┏┓┃ / 6 ┛┗┛┗┛┃ノ) 7 ┓┏┓┏┓┃ 8 ┛┗┛┗┛┃ 9 ┓┏┓┏┓┃ 10 ┛┗┛┗┛┃ 11 ┓┏┓┏┓┃ 12 ┛┗┛┗┛┃ 13 ┓┏┓┏┓┃ 14 ┃┃┃┃┃┃ 15 ┻┻┻┻┻┻ 16 */ 17 #include <algorithm> 18 #include <iostream> 19 #include <iomanip> 20 #include <cstring> 21 #include <climits> 22 #include <complex> 23 #include <fstream> 24 #include <cassert> 25 #include <cstdio> 26 #include <bitset> 27 #include <vector> 28 #include <deque> 29 #include <queue> 30 #include <stack> 31 #include <ctime> 32 #include <set> 33 #include <map> 34 #include <cmath> 35 using namespace std; 36 #define fr first 37 #define sc second 38 #define cl clear 39 #define BUG puts("here!!!") 40 #define W(a) while(a--) 41 #define pb(a) push_back(a) 42 #define Rint(a) scanf("%d", &a) 43 #define Rll(a) scanf("%I64d", &a) 44 #define Rs(a) scanf("%s", a) 45 #define Cin(a) cin >> a 46 #define FRead() freopen("in", "r", stdin) 47 #define FWrite() freopen("out", "w", stdout) 48 #define Rep(i, len) for(int i = 0; i < (len); i++) 49 #define For(i, a, len) for(int i = (a); i < (len); i++) 50 #define Cls(a) memset((a), 0, sizeof(a)) 51 #define Clr(a, x) memset((a), (x), sizeof(a)) 52 #define Full(a) memset((a), 0x7f7f7f, sizeof(a)) 53 #define lrt rt << 1 54 #define rrt rt << 1 | 1 55 #define pi 3.14159265359 56 #define RT return 57 #define lowbit(x) x & (-x) 58 #define onecnt(x) __builtin_popcount(x) 59 typedef long long LL; 60 typedef long double LD; 61 typedef unsigned long long ULL; 62 typedef pair<int, int> pii; 63 typedef pair<string, int> psi; 64 typedef pair<LL, LL> pll; 65 typedef map<string, int> msi; 66 typedef vector<int> vi; 67 typedef vector<LL> vl; 68 typedef vector<vl> vvl; 69 typedef vector<bool> vb; 70 71 const int maxn = 110; 72 typedef struct Node { 73 string name; 74 int n, idx; 75 int t, p, g; 76 }Node; 77 int n; 78 Node p[maxn]; 79 80 int judge(string tmp) { 81 if(tmp[0]==tmp[1]&&tmp[1]==tmp[3]&&tmp[3]==tmp[4]&&tmp[4]==tmp[6]&&tmp[6]==tmp[7]) return 1; 82 if(tmp[0]>tmp[1]&&tmp[1]>tmp[3]&&tmp[3]>tmp[4]&&tmp[4]>tmp[6]&&tmp[6]>tmp[7]) return 2; 83 return 3; 84 } 85 86 bool cmp1(Node a, Node b) { 87 if(a.t == b.t) return a.idx < b.idx; 88 return a.t > b.t; 89 } 90 91 bool cmp2(Node a, Node b) { 92 if(a.p == b.p) return a.idx < b.idx; 93 return a.p > b.p; 94 } 95 96 bool cmp3(Node a, Node b) { 97 if(a.g == b.g) return a.idx < b.idx; 98 return a.g > b.g; 99 } 100 101 int main() { 102 // FRead(); 103 string tmp; 104 while(~Rint(n)) { 105 int cur; 106 For(i, 1, n+1) { 107 cin >> p[i].n >> p[i].name; 108 p[i].t = p[i].p = p[i].g = 0; 109 p[i].idx = i; 110 Rep(j, p[i].n) { 111 cin >> tmp; 112 int q = judge(tmp); 113 if(q == 1) p[i].t++; 114 else if(q == 2) p[i].p++; 115 else if(q == 3) p[i].g++; 116 } 117 } 118 119 sort(p+1,p+n+1,cmp1); 120 printf("If you want to call a taxi, you should call: "); 121 cout << p[1].name; 122 cur = p[1].t; 123 For(i, 2, n+1) { 124 if(p[i].t == cur) cout << ", " << p[i].name; 125 else break; 126 } 127 cout << "." << endl; 128 129 sort(p+1,p+n+1,cmp2); 130 printf("If you want to order a pizza, you should call: "); 131 cout << p[1].name; 132 cur = p[1].p; 133 For(i, 2, n+1) { 134 if(p[i].p == cur) cout << ", " << p[i].name; 135 else break; 136 } 137 cout << "." << endl; 138 139 sort(p+1,p+n+1,cmp3); 140 printf("If you want to go to a cafe with a wonderful girl, you should call: "); 141 cout << p[1].name; 142 cur = p[1].g; 143 For(i, 2, n+1) { 144 if(p[i].g == cur) cout << ", " << p[i].name; 145 else break; 146 } 147 cout << "." << endl; 148 } 149 RT 0; 150 }