SCAU计算智能OJ 18290 校赛排名2

Description

下面是校赛的排名规则:
比赛期间,提交代码后,系统会返回正确或错误等结果。最后的获胜者为正确解答题目最多,如果同题数则总用时最少的队伍。
每道试题的时间花费将从竞赛开始到试题提交并且被判定为正确为止,其间每一次提交运行结果被判错误的话将被加罚20分钟时间,
未正确解答的试题不记时,如果已经返回正确的题目再重复提交则不影响结果。
例如:A、B两队都正确完成两道题目,其中A队提交这两题的时间分别是比赛开始后60分钟和165分钟,B队为80分钟和130分钟,
但B队第一个题提交了2次才通过。这样A队的总用时为60+165=225而B队为(80+20)+130=230,所以A队以总用时少而获胜。
现在给出裁判机上面所有队伍的提交时间(分钟数)和返回结果,需要你编程输出当前比赛的排行榜。

注:0题的队伍不需要输出


 

输入格式

每行一个评判结果,格式为:时间(第几分钟提交的)+半角空格+队名+半角空格+题号+半角空格+评判结果(0通过,其它为出错)

题号由大写A字符开始,第2题是B,依次类推,最多不超过15题
所有评判结果已经按时间排序好


 

输出格式

输出排名,一行一个,格式为队名+半角空格+通过题数+半角空格+罚时

注:0题的队伍不需要输出
测试数据中,没有同题且同罚时的情况


 

 

输入样例

2 abc A 4
5 abc B 0
6 def A 0
10 abc A 0
13 xyx A 4
20 def B 5


 

输出样例

abc 2 35
def 1 6

 

#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

struct data
{
    char name[20];
    int ac;
    int time;
    int problem[15];
};

int checkname(char* name,vector<struct data> V)
{
    for(int i = 0;i < V.size();i++)
    {
        if(!strcmp(name,V[i].name))
            return i;
    }
    return -1;
}

bool cmp(struct data a,struct data b)
{
    if(a.ac > b.ac)
        return true;
    else if(a.ac == b.ac && a.time < b.time)
        return true;
    else
        return false;
}

int main()
{
    int curtime;
    char name[20];
    char problem;
    int code;
    int sign;
    vector<struct data> V;
    while(scanf("%d %s %c %d",&curtime,name,&problem,&code)>0)
    {
        sign = checkname(name,V);
        if(sign == -1)
        {
            struct data temp;
            strcpy(temp.name,name);
            if(code == 0)
            {
                temp.ac = 1;
                memset(temp.problem,0,sizeof(int)*15);
                temp.problem[problem-'A'] = -1;
                temp.time = curtime;
            }
            else
            {
                temp.ac = 0;
                memset(temp.problem,0,sizeof(int)*15);
                temp.problem[problem-'A'] = 1;
                temp.time = 0;
            }
            V.push_back(temp);
        }
        else
        {
            if(code == 0 && V[sign].problem[problem-'A'] != -1)
            {
                V[sign].time += curtime;
                V[sign].time += V[sign].problem[problem-'A'] * 20;
                V[sign].problem[problem-'A'] = -1;
                V[sign].ac++;
            }
            if(code != 0)
            {
                V[sign].problem[problem-'A']++;
            }
        }

    }
    stable_sort(V.begin(),V.end(),cmp);
    for(int i = 0;i < V.size();i++)
    {
        if(V[i].ac > 0)
            cout << V[i].name << " " << V[i].ac << " " << V[i].time << endl;
    }

    return 0;
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值