zoukankan      html  css  js  c++  java
  • 构造 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 */
    编译人生,运行世界!
  • 相关阅读:
    【转载】MDX 去年当月值、差值、同比
    【原创】Analyzer安全性异常(应用程序视图执行安装策略不允许的操作)
    Analyzer普通用户登录不了[从网络访问此计算机]
    【转载】51CTO如何防止SQL注入的解决方法
    【转载】51CTOAndroidManifest.xml文件详解
    Eclipse插件安装方式
    Typemock揭示 安装其它三方软件可能引起冲突,那试试不安装直接引用它的DLL
    项目从VS2010 升 VS2012 遇到的代表性问题及解决
    c# comboBox模糊匹配
    sqlJDBC安装使用
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4656706.html
Copyright © 2011-2022 走看看