HDU 2384 | POJ 2920 | Ranking 模拟
来源:互联网 发布:淘宝双11和双12 编辑:程序博客网 时间:2024/05/19 18:12
被这道题虐死了,是被题目虐了,不是被人虐了 排名规则不讲清楚~WA无数次 最后死在了这一题上面一直死到了最后~
题意:
ACM比赛排名,排名规则如下:
1、按A题数(降序)
2、题数相同按总时间(升序)
3、
①最后A掉的那一题的时间,不包括罚时(升序)
②最后A掉的那一题的时间,包括罚时(降序)
3、递归前一题,直道最后一题
4、以上都符合,队名按字典排序(升序)
分析:
直接模拟吧~ qsort()大展拳脚
//AC CODE:
#include<iostream>#include<cmath>#include<algorithm>#include<vector>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<map>using namespace std;int cas,t,r;struct Team{ char name[25]; int pid[15]; int pid_fs[15]; int icount; int tol_time; int a[15],fa[15];//从1开始} team[55];int findTeam(char xx[]){ for(int i=0; i<t; i++) if(strcmp(xx,team[i].name)==0) return i; return -1;}int cmp( const void *a , const void *b ){ struct Team *c = (Team *)a; struct Team *d = (Team *)b; if(c->icount != d->icount) return d->icount - c->icount;//总题数降序 else if(c->tol_time!=d->tol_time) return c->tol_time - d->tol_time;//总时间升序 else { for(int i=c->icount; i>=1; i--) { if(c->a[i] != d->a[i]) return c->a[i] - d->a[i];//A题时间升序 else if(c->fa[i] != d->fa[i]) return d->fa[i] - c->fa[i];//A题+罚时降序 } } return strcmp(c->name,d->name);}void print(){ printf("1 %s %d %d\n",team[0].name,team[0].icount,team[0].tol_time); int c1=1,c2=1; for(int i=1; i<t; i++) { if(team[i-1].icount==team[i].icount) { if(team[i-1].tol_time==team[i].tol_time) { for(int j=team[i].icount; j>=1; j--) { if(team[i-1].a[j]==team[i].a[j]) { if(team[i-1].fa[j]==team[i].fa[j]) { ; } else { c1=c1+c2; printf("%d %s %d %d\n",c1,team[i].name,team[i].icount,team[i].tol_time); c2=1; goto to; } } else { c1=c1+c2; printf("%d %s %d %d\n",c1,team[i].name,team[i].icount,team[i].tol_time); c2=1; goto to; } } c2++; printf("%d %s %d %d\n",c1,team[i].name,team[i].icount,team[i].tol_time);to: ; } else { c1=c1+c2; printf("%d %s %d %d\n",c1,team[i].name,team[i].icount,team[i].tol_time); c2=1; } } else { c1=c1+c2; printf("%d %s %d %d\n",c1,team[i].name,team[i].icount,team[i].tol_time); c2=1; } }}int main(){ //freopen("in.txt", "r", stdin); scanf("%d",&cas); int ti,index,id; char name[25],res[15],ch; while(cas--) { scanf("%d %d",&t,&r); for(int i=0; i<t; i++) { scanf("%s",team[i].name); team[i].tol_time=0; team[i].icount=0; for(int j=0; j<15; j++) { team[i].pid[j]=0; team[i].pid_fs[j]=0; } } for(int i=0; i<r; i++) { scanf("%d %s %c %s",&ti,name,&ch,res); if(ti<=300) { index=findTeam(name); if(index==-1) continue; id=ch-'A'; if(team[index].pid[id]==1)//已经做出来了 continue; else { if(strcmp(res,"accepted")==0) { team[index].tol_time+=ti+team[index].pid_fs[id]; team[index].pid[id]=1; team[index].icount++; // team[index].a[team[index].icount]=ti; team[index].fa[team[index].icount]=ti+team[index].pid_fs[id]; } else { team[index].pid_fs[id]+=20; } } } } qsort(team,t,sizeof(team[0]),cmp); print(); }}
- HDU 2384 | POJ 2920 | Ranking 模拟
- ZOJ 3770 Ranking System 模拟
- ZOJ 3770 Ranking System(模拟)
- POJ 3275 Ranking The Cows
- poj 3275 Ranking the Cows
- Poj 3275 Ranking the Cows
- poj 3275 Ranking The Cows
- Ranking
- HDU 1361 & POJ 1068 Parencodings(模拟)
- HDU 1035 && poj 1573 Robot Motion【模拟】
- poj 3275 Ranking the Cows 图+BFS
- poj 3275 Ranking the Cows floyd算法
- POJ 1573 && hdu 1035 Robot Motion【简单模拟】
- POJ 3344 & HDU 2414 Chessboard Dance(模拟)
- POJ 3923 & HDU 2487 Ugly Windows(模拟)
- POJ 3488 & HDU 1915 Arne Saknussemm(模拟)
- POJ 3505 && HDU 2341 Tower Parking(简单模拟)
- poj 1218&&hdu 1337 The Drunk Jailer【简单模拟】
- Oracle Flashback 技术总结
- 动态生成WORD内容
- 构件图(Component Diagram)—UML图(八)
- 用两个栈实现一个队列的功能?要求给出算法和思路!
- joj1175
- HDU 2384 | POJ 2920 | Ranking 模拟
- 《java编程思想》第22章练习6
- WORD LIST 2
- sendToTarget与sendMessage
- oprofile在android下的常见问题
- error C2018: unknown character '0xa1' 有非法字符
- android-加载sd卡的图片并显示
- 排序系列--待续。。。
- struts2学习(1)简述Struts2的基本原理