2019河北CCPC省赛 D单

#include <bits/stdc++.h>
using namespace std;
 
int n;
 
int get_time(string &s) {
    if(s=="GAME") return -1;
    return (s[1]-'0')*60+(s[3]-'0')*10+(s[4]-'0');
}
 
int get_state(string &s) {
    if(s=="Accepted") return 1;
    if(s=="Wrong Answer") return 2;
    if(s=="Time Limit Exceeded") return 2;
    if(s=="Memory Limit Exceeded") return 2;
    if(s=="Output Limit Exceeded") return 2;
    if(s=="Runtime Error") return 2;
    if(s=="Presentation Error") return 2;
    if(s=="Compile Error") return 3;
    return -1;
}
 
map<string,int> team_id;
int tot=0;
 
struct TEAM {
    string name;
    bool ac[20];
    int ac_tim[20], penty[20];
    int AC, P, AVA;
 
    void process_state(int ty,int id,int t) {
        if(ty==3 || ac[id]) return;
        AVA=true;
        if(ty==2) penty[id]++;
        else {
            ac_tim[id]=t;
            ac[id]=true;
        }
        return;
    }
 
    void final_calc() {
        register int i;
        for(i=0;i<n;++i) AC+=ac[i];
        for(i=0;i<n;++i) if(ac[i])
            P+=penty[i]*20+ac_tim[i];
        return;
    }
 
    bool operator < (const TEAM &rhs) const {
        if(AC!=rhs.AC) return AC>rhs.AC;
        if(P!=rhs.P) return P<rhs.P;
        return name<rhs.name;
    }
 
}sta[2333];
 
int rnk[2333];
 
int main() {
    scanf("%d\n",&n);
    while(true) {
        string tmp="";
        char ch;
 
        tmp="";
        while((ch=getchar())!=' ') tmp+=ch;
        int tim=get_time(tmp);
        if(!~tim) break;
         
        tmp="";
        while((ch=getchar())!=' ') tmp+=ch;
        int pro_id=tmp[0]-'A';
 
        tmp="";
        while(ch=getchar()) {
            tmp+=ch;
            if(~get_state(tmp)) {getchar(); break;}
            else continue;
        }
        int statu=get_state(tmp);
 
        tmp="";
        while((ch=getchar())!='\n') tmp+=ch;
         
        if(team_id.find(tmp)==team_id.end()) {
            team_id.insert(make_pair(tmp,++tot));
            sta[tot].name=tmp;
        }
        int id=team_id[tmp];
        sta[id].process_state(statu,pro_id,tim);

    }
 
    register int i;
    int max_len=0;
    for(i=1;i<=tot;++i) {
        sta[i].final_calc();
        int len=sta[i].name.size();
        max_len=max(max_len,len);
    }
    sort(sta+1,sta+1+tot);
     
    rnk[1]=1;
    for(i=2;i<=tot;++i) {
        if(sta[i].AC==sta[i-1].AC && sta[i].P==sta[i-1].P) rnk[i]=rnk[i-1];
        else rnk[i]=rnk[i-1]+1;
    }
 
    printf("Rank");
    printf("  Who");
    for(i=1;i<=max_len-3;++i) putchar(' ');
    printf("  Solved");
    printf("  Penalty");
    for(i=0;i<n;++i) printf("    %c",'A'+i);
    putchar('\n');
 
    for(i=1;i<=tot;++i) if(sta[i].AVA) {
        if(i>1) putchar('\n');
        printf("%4d",rnk[i]);
        int space_num=max_len-sta[i].name.size()+2;
        while(space_num--) putchar(' ');
        cout<<sta[i].name;
        printf("  %6d",sta[i].AC);
        printf("  %7d",sta[i].P);
 
        for(int j=0;j<n;++j) {
            if(sta[i].ac[j]) {
                if(!sta[i].penty[j]) printf("    +");
                else if(sta[i].penty[j]<10) printf("   +%d",sta[i].penty[j]);
                else printf("  +%d",sta[i].penty[j]);
            } else {
                if(!sta[i].penty[j]) printf("     ");
                else if(sta[i].penty[j]<10) printf("   -%d",sta[i].penty[j]);
                else printf("  -%d",sta[i].penty[j]);
            }
        }
 
    }
    return 0;
}

在牛客上down的别人的,反正我是没心情写这么恶心的大模拟。

发布了183 篇原创文章 · 获赞 31 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/mlm5678/article/details/90580227