• hdu 1225大水题


    /*
     * hdu1225/win.cpp
     * Created on: 2013-5-31
     * Author    : ben
     */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    using namespace std;
    #ifndef ONLINE_JUDGE
    const int MAXN = 60;
    #else
    const int MAXN = 6000;
    #endif
    typedef struct Person {
        char name[40];
        int win;
        int lost;
        int score;
    }Person;
    
    Person persons[MAXN];
    map<string, int> mymap;
    int pn;
    
    inline int getNameId(const char *str) {
        string temp(str);
        if(mymap.count(temp) > 0) {
            return mymap[temp];
        }
        strcpy(persons[pn].name, str);
        mymap[temp] = pn;
        return pn++;
    }
    
    inline bool operator<(const Person& p1, const Person& p2) {
        if(p1.score != p2.score) {
            return p1.score > p2.score;
        }
        if(p1.win - p1.lost != p2.win - p2.lost) {
            return p1.win - p1.lost > p2.win - p2.lost;
        }
        if(p1.win != p2.win) {
            return p1.win > p2.win;
        }
        return string(p1.name) < string(p2.name);
    }
    
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("data.in", "r", stdin);
    #endif
        char name1[40], name2[40];
        int N, n, a, b;
        while(scanf("%d", &n) == 1) {
            memset(persons, 0, sizeof(persons));
            mymap.clear();
            N = n * (n - 1);
            pn = 0;
            while(N--) {
                scanf(" %s VS %s %d:%d", name1, name2, &a, &b);
                int i = getNameId(name1);
                int j = getNameId(name2);
                persons[i].win += a;
                persons[i].lost += b;
                persons[j].win += b;
                persons[j].lost += a;
                if(a > b) {
                    persons[i].score += 3;
                }else if(a < b) {
                    persons[j].score += 3;
                }else {
                    persons[i].score++;
                    persons[j].score++;
                }
            }
            sort(persons, persons + n);
            for(int i = 0; i < n; i++) {
                printf("%s %d\n", persons[i].name, persons[i].score);
            }
            putchar('\n');
        }
        return 0;
    }
  • 相关阅读:
    东南大学2021年高等代数
    北京师范大学2021年数学分析
    华东师范大学2021年数学分析考研试题参考解答修正版
    中国科学院大学2021年数学分析考研试题参考解答
    [数学考研竞赛00052]浙江大学2021年数学分析考研试题参考解答
    python3.6, cv2.imread()导入图片失败,none
    python商品分类信息
    mongodb 聚合(Map-Reduce)
    mongodb 聚合(aggregate)
    Java-Security(七):Spring Security方法注解认证启用
  • 原文地址:https://www.cnblogs.com/moonbay/p/3111712.html
Copyright © 2020-2023  润新知