zoukankan      html  css  js  c++  java
  • HNUST-1148 ACM ranking rules(简单模拟)

    1148: ACM ranking rules

    时间限制: 1 Sec  内存限制: 128 MB
    提交: 16  解决: 12
    [提交][状态][讨论版]

    题目描述

    ACM contests, like the one you are participating in, are hosted by the special software. That software, among other functions, preforms a job of accepting and evaluating teams' solutions (runs), and displaying results in a rank table. The scoring rules are as follows:

    1.         Each run is either accepted or rejected.

    2.         The problem is considered solved by the team, if one of the runs submitted for it is accepted.

    3.         The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submission of the first accepted run for this problem (in minutes) plus 20 minutes for every other run for this problem before the accepted one. For an unsolved problem consumed time is not computed.

    4.         The total time is the sum of the time consumed for each problem solved.

    5.         Teams are ranked according to the number of solved problems. Teams that solve the same number of problems are ranked by the least total time.

    6.         While the time shown is in minutes, the actual time is measured to the precision of 1 second, and the the seconds are taken into account when ranking teams.

    7.         Teams with equal rank according to the above rules must be sorted by increasing team number.

    Your task is, given the list of N runs with submission time and result of each run, compute the rank table for C teams.

    输入

    Input contains integer numbers C N, followed by N quartets of integers ci pi ti ri, where ci -- team number, pi -- problem number, ti -- submission time in seconds, ri -- 1, if the run was accepted, 0 otherwise.

    1 ≤ C, N ≤ 1000, 1 ≤ ci ≤ C, 1 ≤ pi ≤ 20, 1 ≤ ti ≤ 36000.

    输出

    Output must contain C integers -- team numbers sorted by rank.

    样例输入

    3 3
    1 2 3000 0
    1 2 3100 1
    2 1 4200 1
    

    样例输出

    2 1 3
    

    提示

    用结构体数组存储各队信息

    #include<algorithm>
    #include<iostream>
    #include<cstdio>
    #include<map>
    using namespace std;
     
    const int N = 1000 + 5;
     
    int c, n;
    struct node{
        short _time = 0, solve = 0, num;
        map<int, int> state;
    }Node[N];
     
    int main(){
        scanf("%d %d", &c, &n);
        for(int i = 1; i <= c; i++) Node[i].num = i;
     
        int ci, pi, ti, ri;
        for(int i = 1; i <= n; i++){
            scanf("%d %d %d %d", &ci, &pi, &ti, &ri);
            auto & mp = Node[ci].state;
            if(mp[pi] < 0) continue;
            if(ri == 0 ) mp[pi]++;
            if(ri == 1) {
                Node[ci]._time += (mp[pi] * 20 * 60 + ti);
                mp[pi] = -1;
                Node[ci].solve++;
            }
        }
        auto cmp = [](const node &x, const node &y) -> bool{
            if(x.solve != y.solve) return x.solve > y.solve;
            return x._time < y._time;
        };
        stable_sort(Node + 1, Node + n + 1, cmp);
        for(int i = 1; i <= n; i++){
            printf("%d%c", Node[i].num, (i == n)?'
    ':' ');
        }
    }
  • 相关阅读:
    用GDB调试程序(一)
    关于“鸡脚神”的看法
    Oracle 经典SQL 专为笔试准备
    怎样设计接口?
    myeclipse6.0下载及注冊码
    VB连接Mysql数据库
    开源html5_kiwijs_helloworld
    server宕机监控、检測、报警程序(139绑定手机短信报警)monitor_down.sh
    js实现自己定义鼠标右键-------Day45
    C/C++程序猿必须熟练应用的开源项目
  • 原文地址:https://www.cnblogs.com/Pretty9/p/7784912.html
Copyright © 2011-2022 走看看