UVa 10258 - Contest Scoreboard
来源:互联网 发布:h3c mac过滤 编辑:程序博客网 时间:2024/05/17 04:40
还是改不了自己狂卡题的坏毛病 -_-,这回是卡输出上了
这是一道比较简单的一道OJ比赛排行榜的模拟题,练代码能力,直接贴代码
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>using namespace std;struct team{ int num;//记录该队的序号 int time;//用来存储该队的总罚时 int ac;//用来存储该队的ac数目 bool vis;//用来标记该队是否交过题 bool tnum[11];//题号,用来标记是否做出该题 int tt[11];//单个题目的罚时} p[105];int cmp(const void *_x,const void *_y) //对各队进行排序,我们熟知,第一关键字是ac数(降序),第二关键字是总罚时(升序){ team *x=(team *)_x; team *y=(team *)_y; if(x->vis==y->vis) { if(x->ac==y->ac) return x->time-y->time; return y->ac-x->ac; } return y->vis-x->vis;}int main(){ int a,b,t; char k; int ncase; cin>>ncase; getchar(); getchar(); while(ncase--) { char s[300]; int n=0; for(int i=1; i<=100; i++)//初始化 { p[i].num=i; p[i].ac=0; p[i].time=0; p[i].vis=0; for(int j=0;j<=10;j++) { p[i].tnum[j]=0; p[i].tt[j]=0; } } while(gets(s)!=NULL) { if(strlen(s)<2)break; sscanf(s,"%d %d %d %c",&a,&b,&t,&k); p[a].vis=1; if(!p[a].tnum[b]&&k=='C')//如果有题目AC了,将题目标记,以后的提交无效 { p[a].tnum[b]=1; p[a].tt[b]+=t; } if(!p[a].tnum[b]&&k=='I')//在题目未AC前将罚时存入 { p[a].tt[b]+=20; } n++; } for(int i=1; i<=100; i++) { for(int j=1; j<=9; j++) { if(p[i].tnum[j]) { p[i].ac++; p[i].time+=p[i].tt[j]; } } } qsort(p+1,100,sizeof(p[0]),cmp); for(int i=1; i<=100; i++) { if(!p[i].vis)break; cout<<p[i].num<<" "<<p[i].ac<<" "<<p[i].time<<endl; } if(ncase)cout<<endl;//两组样例之间要输出空行 } return 0;}
- uva 10258 - Contest Scoreboard
- UVa 10258 - Contest Scoreboard
- UVA 10258 Contest Scoreboard
- UVA 10258 Contest Scoreboard
- UVa 10258 Contest Scoreboard
- UVa 10258 - Contest Scoreboard
- Uva 10258 Contest Scoreboard
- UVA 10258 Contest Scoreboard
- uva 10258Contest Scoreboard
- UVa OJ 10258 - Contest Scoreboard
- UVa Problem Solution: 10258 - Contest Scoreboard
- 10258 - Contest Scoreboard
- UVa Problem 10258 Contest Scoreboard (比赛计分板)
- Contest Scoreboard
- fjnu 1557 Contest Scoreboard
- 110207 Contest Scoreboard
- (挑战编程_2_7)Contest Scoreboard
- programming-challenges Contest Scoreboard (110207) 题解
- windows 8 启动自动加载VHD存储池
- [转]HTML5新功能演示
- Android SQLite总结(一)
- 枚举 转换
- 【重新上本科】排序【调试环境】
- UVa 10258 - Contest Scoreboard
- struts2常用标签
- QueryPerformanceCounter/QueryPerformance
- Android通过共享用户ID来实现多Activity进程共享
- 单数行一个颜色,双数行一个颜色
- virtual关键字与多态
- 各种MySQL索引类型的介绍
- GBK和Utf-8字符串截取函数
- 怎么有效利用碎片时间的?