构造 Codeforces Round #107 (Div. 2) B. Phone Numbers

 

题目传送门

 1 /*  2  构造:结构体排个序,写的有些啰嗦,主要想用用流,少些了判断条件WA好几次:(  3 */  4 #include <cstdio>  5 #include <algorithm>  6 #include <cstring>  7 #include <cmath>  8 #include <vector>  9 #include <map>  10 #include <iostream>  11 #include <string>  12 using namespace std;  13  14 const int MAXN = 1e2 + 10;  15 const int INF = 0x3f3f3f3f;  16 struct Phone  17 {  18 string name;  19 string num[MAXN];  20 int tot, t, p, g, id;  21 }p[MAXN];  22  23 bool cmp_t(Phone x, Phone y)  24 {  25 if (x.t == y.t) return x.id < y.id;  26 return x.t > y.t;  27 }  28  29 bool cmp_p(Phone x, Phone y)  30 {  31 if (x.p == y.p) return x.id < y.id;  32 return x.p > y.p;  33 }  34  35 bool cmp_g(Phone x, Phone y)  36 {  37 if (x.g == y.g) return x.id < y.id;  38 return x.g > y.g;  39 }  40  41 int main(void) //Codeforces Round #107 (Div. 2) B. Phone Numbers  42 {  43 // freopen ("C.in", "r", stdin);  44  45 int n;  46 while (cin >> n)  47  {  48 for (int i=1; i<=n; ++i)  49  {  50 cin >> p[i].tot >> p[i].name; p[i].id = i;  51 p[i].t = p[i].p = p[i].g = 0;  52 for (int j=1; j<=p[i].tot; ++j)  53  {  54 cin >> p[i].num[j];  55 if (p[i].num[j][0] == p[i].num[j][1] && p[i].num[j][1] == p[i].num[j][3] &&  56 p[i].num[j][3] == p[i].num[j][4] && p[i].num[j][4] == p[i].num[j][6] &&  57 p[i].num[j][6] == p[i].num[j][7]) p[i].t++;  58 else if (p[i].num[j][0] > p[i].num[j][1] && p[i].num[j][1] > p[i].num[j][3] &&  59 p[i].num[j][3] > p[i].num[j][4] && p[i].num[j][4] > p[i].num[j][6] &&  60 p[i].num[j][6] > p[i].num[j][7]) p[i].p++;  61  }  62 p[i].g = p[i].tot - p[i].t - p[i].p;  63 // cout << p[i].t << " " << p[i].p << " " << p[i].g << endl;  64  }  65  66 int pre = 0;  67 sort (p+1, p+1+n, cmp_t);  68 cout << "If you want to call a taxi, you should call: ";  69 for (int i=1; i<=n; ++i)  70  {  71 if (i == 1)  72  {  73 cout << p[i].name; pre = p[i].t;  74  }  75 else if (p[i].t == pre) cout << ", " << p[i].name;  76 else break;  77  }  78 cout << "." << endl;  79 sort (p+1, p+1+n, cmp_p);  80 cout << "If you want to order a pizza, you should call: ";  81 for (int i=1; i<=n; ++i)  82  {  83 if (i == 1)  84  {  85 cout << p[i].name; pre = p[i].p;  86  }  87 else if (p[i].p == pre) cout << ", " << p[i].name;  88 else break;  89  }  90 cout << "." << endl;  91 sort (p+1, p+1+n, cmp_g);  92 cout << "If you want to go to a cafe with a wonderful girl, you should call: ";  93 for (int i=1; i<=n; ++i)  94  {  95 if (i == 1)  96  {  97 cout << p[i].name; pre = p[i].g;  98  }  99 else if (p[i].g == pre) cout << ", " << p[i].name; 100 else break; 101  } 102 cout << "." << endl; 103  } 104 105 return 0; 106 } 107 108 /* 109 If you want to call a taxi, you should call: Rogulenko. 110 If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin. 111 If you want to go to a cafe with a wonderful girl, you should call: Melnikov. 112 */

 

你可能感兴趣的:(codeforces)