UVa 10258 - Contest Scoreboard

题目: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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值