ACM Rank Table

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.
The problem is considered solved by the team, if one of the runs submitted for it is accepted.
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.
The total time is the sum of the time consumed for each problem solved.
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.
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.
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
Input contains integer numbers C N, followed by N quartets of integes 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
Output must contain C integers – team numbers sorted by rank.
Sample Input
3 3
1 2 3000 0
1 2 3100 1
2 1 4200 1
Sample Output
2 1 3

题意:
要求按 解题数——>时间数(总时间)——>队伍编号(小的在前)的优先次序排序然后输出

坑:这个排序十分接近实际了,一个队伍可以多次提交,系统只记录第一次AC的那个时间,之后的提交不论情况如何都会被忽略的,罚时也只记录打一次AC之前的罚时
思路:先按提交时间的先后顺序进行排序然后再按上面所说优先次序排序即可

#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<list>
#include<iterator>
#include<stack>
#include <queue>
#include <cstdio>
#include<algorithm>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
#define e 2.718281828459
#define INF 0x7fffffff
#pragma warning(disable:4996)
#define sf scanf
#define pf printf
const double pi = acos(-1.0);
const int falti = 1200;
//#define  eps 1e-9;


struct Node {
    int num;
    int solve;//0
    ull time;//0
    int fal[20];//0
    bool suc[20];
};

struct Question {
    int num;//队
    int ci;//题号
    int time;//解决时间
    int judge;//是否解决

};

bool cmp(const Node& a, const Node& b) {
    /*if (a.solve > b.solve)//下面的写法更好
        return true;
    else if (a.solve < b.solve)
        return false;
    else {
        if (a.time < b.time)
            return true;
        else if (a.time > b.time)
            return false;
        else {
            return a.num > b.num;
        }
    }*/

    if (a.solve != b.solve)
        return a.solve > b.solve;
    else if (a.time != b.time)
        return  a.time < b.time;
    else
        return a.num < b.num;

}

bool cmpbytime(const Question& a, const Question& b) {
    return a.time < b.time;
}

int main(void) {
    Node node[1002];
    Question que[1002];
    int c, n;
    sf("%d %d", &c, &n);
    memset(node, 0, sizeof node);

    for (int i = 1; i <= c; i++) {
        node[i].num = i;
    }
    for (int i = 1; i <= n; i++) {
        sf("%d %d %d %d", &que[i].num, &que[i].ci, &que[i].time, &que[i].judge);
    }

    sort(que + 1, que + 1 + n, cmpbytime);

    /*int ci, pi, ti, ri=0;
    while (n--) {
        sf("%d %d %d %d", &ci, &pi, &ti, &ri);
        if (ri == 0) {
            node[ci].fal[pi]++;
        }

        else {
            node[ci].solve++;
            node[ci].time += node[ci].fal[pi] * falti+ti;
            node[ci].fal[pi] = 0;
        }
    }*/

    for (int i = 1; i <= n; i++) {
        int team = que[i].num;//队名
        int cc = que[i].ci;//题编号

        if (node[team].suc[cc]  == true)
            continue;
        else {
            if (que[i].judge == 0) {
                node[team].fal[cc]++;

            }
            else {
                node[team].solve++;
                node[team].time += que[i].time + node[team].fal[cc] * 1200;
                //总时间累加
                node[team].suc[cc] = true;
            }
        }
    }

    sort(node + 1, node + 1 + c, cmp);

    for (int i = 1; i <= c; i++) {
        pf("%d ", node[i].num);
    }
    pf("\n");

    return 0;
}

猜你喜欢

转载自blog.csdn.net/jiruqianlong123/article/details/81665913
ACM