POJ 2379 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.
  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

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

 

这个题坑点多,首先第一次正确提交之后的提交都无效,其次注意题目给的提交顺序不一定是按照时间顺序给出,比方先给你个8000s错误提交,再给你个4000s正确提交,需要自己先排一下序。用sort函数可以有效避免一些不好查出的错误

 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int c,n;
struct node {
    int time,problem,rank;
};
int table[1020][1020];
int p[1020][1020];
struct input{
    int ci,pi,ti,ri;
};
struct input in[1000];
int main()
{
    struct node a[1020];
    memset(table,0,sizeof(table));
    memset(p,0,sizeof(p));

    scanf("%d%d",&c,&n);
    for(int i=1;i<=c;i++){
        a[i].rank=i;
        a[i].time=0;
        a[i].problem=0;
    }

    for(int i=0;i<n;i++){
        scanf("%d%d%d%d",&in[i].ci,&in[i].pi,&in[i].ti,&in[i].ri);
    }

    for(int i=0;i<n;i++){
        int flag=1;
        for(int j=0;j<n-i-1;j++){
            if(in[j].ti>in[j+1].ti){
                struct input t=in[j];
                in[j]=in[j+1];
                in[j+1]=t;
                flag=0;
            }
        }
        if(flag)break;
    }

    for(int i=0;i<n;i++){
        if(p[in[i].ci][in[i].pi])continue;
        if(in[i].ri){
            a[in[i].ci].problem+=1;
            a[in[i].ci].time+=in[i].ti+table[in[i].ci][in[i].pi]*1200;
            p[in[i].ci][in[i].pi]=1;
        }
        else {
            table[in[i].ci][in[i].pi]+=1;
        }
    }

    for(int i=1;i<=c;i++){
        int flag=1;
        for(int j=1;j<=c-i;j++){
            if(a[j].problem<a[j+1].problem ||
               a[j].problem==a[j+1].problem&&a[j].time>a[j+1].time
               ){
                struct node b=a[j];
                a[j]=a[j+1];
                a[j+1]=b;
                flag=0;
            }
        }

//        for(int i=1;i<=c;i++){
//        printf("%d %d %d",a[i].rank,a[i].problem,a[i].time);
//        if(i!=c)printf("***");
//        else printf("\n");
//    }
        if(flag)break;
    }

    for(int i=1;i<=c;i++){
        printf("%d",a[i].rank);
        if(i!=c)printf(" ");
        else printf("\n");
    }
    return 0;
}

题目链接: 

https://cn.vjudge.net/problem/POJ-2379 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值