UVa 10258 - Contest Scoreboard

来源:互联网 发布:java 架构设计 编辑:程序博客网 时间:2024/05/16 12:34

题目:ACM比赛排版,出题数优先,然后是罚时(第一次AC的时间+AC前这个题目错的次数*20)。

           (想起多年以前在学校写OJ的往事了╮(╯▽╰)╭)

分析:简单题,多级排序。直接按字符串读入数据,然后转化排序,输出即可。

注意:1.没有出题的的队伍也要排序;2.AC过的那道题再次提交不会产生影响。

#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;typedef struct nodec{int  c,p,t;char L;}consists;consists I,C[105];int stats[105][11];//记录每个题目首次AC前的错误次数,如果AC赋值-1 bool cmp( consists a, consists b ){if ( a.p != b.p ) return a.p > b.p;if ( a.t != b.t ) return a.t < b.t;if ( a.c && b.c ) return a.c < b.c;return a.c > b.c;}int main(){int  n;char buf[101];scanf("%d",&n);getchar();getchar();while ( n -- ) {memset( stats, 0, sizeof(stats) );memset( C, 0, sizeof(C) );while ( gets(buf) && buf[0] ) {sscanf(buf,"%d %d %d %c",&I.c,&I.p,&I.t,&I.L);C[I.c].c = I.c;//已经AC的题目 if ( stats[I.c][I.p] == -1 ) continue;//刚刚AC的题目 if ( I.L == 'C' ) {C[I.c].t += stats[I.c][I.p]*20+I.t;C[I.c].p ++;stats[I.c][I.p] = -1;continue;}//首次AC前的错误 if ( I.L == 'I' ) stats[I.c][I.p] ++;}sort( C+1, C+101, cmp );for ( int i = 1 ; C[i].c ; ++ i ) printf("%d %d %d\n",C[i].c,C[i].p,C[i].t);if ( n ) printf("\n");}//system("pause");return 0;}

0 0