2018年内蒙古自治区ICPC逃离机场

逃离机场

这道题做麻烦了。。。

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct node
{
    //int id;//学校编号
    int sum;//ac题目的数量
    int time;//总罚时
    string name ;//学校的名字
    map <char,string> m;
};
typedef struct cmd
{
     int id,time;
     char ti;//ti是题目
     string rs;
};
struct node s[10005];
struct cmd sp[10005];
map <int,int> mmp;
int toInt(string str)
{
    int sum = 0,flag = 1;
    int len = str.size();
    for(int i=len-1;i>=0;i--)
    {
        int a = str[i]-'0';
        sum+=a*flag;
        flag*=10;
    }
    return sum;
}
string toString(int n)
{
    if(n==0)
    {
        return "0";
    }
    string str="",strs="";
    char c;
    while(n)
    {
        int a = n%10;
        c = a+'0';
        str+=c;
        n/=10;
    }
    for(int i=str.size()-1;i>=0;i--)
        strs+=str[i];
    return strs;
}
bool cmp(struct node a, struct node b)
{
    if(a.sum!=b.sum)
        return a.sum>b.sum;
    else if(a.time!=b.time && a.sum==b.sum)
        return a.time<b.time;
    else
        return a.name<b.name;
}
bool cmpd(struct cmd a, struct cmd b)
{
    return a.time<b.time;
}
int main ()
{
    int n,m,k;
    while(cin >> n >> m >> k)
    {
        for(int i=0;i<n;i++)//n所学校
        {
            int a;
            string b;
            cin >> a;
            getchar();
            getline(cin,b);
            mmp[a] = i;
            s[i].name = b;
            s[i].time = 0;
            s[i].sum = 0;
            char cc = 'A';
            for(int j=0;j<m;j++)
            {
                s[i].m[cc] = "0";
                cc+=1;
            }
        }
        for(int i=0;i<k;i++)
        {
            int a,b,c;
            char cc;//ti是题目
            cin>>sp[i].id>>a>>cc>>b>>cc>>c>>sp[i].ti>>sp[i].rs;
            sp[i].time = a*60*60+b*60+c;
        }
        sort(sp,sp+k,cmpd);
        for(int i=0;i<k;i++)
        {
            int id = sp[i].id;
            char ti = sp[i].ti;//ti是题目
            string rs = sp[i].rs;//判题机的结果
            int time = sp[i].time;//该题目提交的时间
            int index = mmp[id];//输入的编号对应的结构体
            if(s[index].m[ti].compare("AC"))//表示该题目没有AC
            {
                if(!rs.compare("Accepted"))//题目AC成功!
                {
                    string times = s[index].m[ti];//对应题目的罚时
                    int f_time = toInt(times);
                    s[index].time += time;//更新时间
                    s[index].time += f_time;//时间要加上这个题的罚时
                    s[index].m[ti] = "AC";//
                    s[index].sum++;//AC题目加1
                }
                //else if(!rs.compare("CompileError"))
                    //continue;
                else
                {
                    int times = toInt(s[index].m[ti]);//获取对应题目的罚时
                    times+=(20*60);//罚时20分钟
                    s[index].m[ti] = toString(times);
                }
            }
        }
        /*
        for(int i=0;i<n;i++)
        {
            cout <<s[i].name<<" "<<s[i].time<< endl;
            map <char,string>::iterator it;
            for(it=s[i].m.begin();it!=s[i].m.end();++it)
                cout << it->first << " " << it->second << endl;
        }
        */
        sort(s,s+n,cmp);
        if(s[0].sum)
            cout << s[0].name << endl;
        else
            cout << "Invalid" << endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值