ACM Rank Table(poj 2397)
来源:互联网 发布:易语言打码挂机源码 编辑:程序博客网 时间:2024/06/05 08:46
Description
ACM contests, like the one you are participating in, are hosted by the special software. That software, among other functions, preforms a job of accepting and evaluating teams' solutions (runs), and displaying results in a rank table. The scoring rules are as follows:
Your task is, given the list of N runs with submission time and result of each run, compute the rank table for C teams.
- Each run is either accepted or rejected.
- The problem is considered solved by the team, if one of the runs submitted for it is accepted.
- The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submission of the first accepted run for this problem (in minutes) plus 20 minutes for every other run for this problem before the accepted one. For an unsolved problem consumed time is not computed.
- The total time is the sum of the time consumed for each problem solved.
- Teams are ranked according to the number of solved problems. Teams that solve the same number of problems are ranked by the least total time.
- While the time shown is in minutes, the actual time is measured to the precision of 1 second, and the the seconds are taken into account when ranking teams.
- Teams with equal rank according to the above rules must be sorted by increasing team number.
Your task is, given the list of N runs with submission time and result of each run, compute the rank table for C teams.
Input
Input contains integer numbers C N, followed by N quartets of integes ci pi ti ri, where ci -- team number, pi -- problem number, ti -- submission time in seconds, ri -- 1, if the run was accepted, 0 otherwise.
1 ≤ C, N ≤ 1000, 1 ≤ ci ≤ C, 1 ≤ pi ≤ 20, 1 ≤ ti ≤ 36000.
1 ≤ C, N ≤ 1000, 1 ≤ ci ≤ C, 1 ≤ pi ≤ 20, 1 ≤ ti ≤ 36000.
Output
Output must contain C integers -- team numbers sorted by rank.
Sample Input
3 31 2 3000 01 2 3100 12 1 4200 1
Sample Output
2 1 3
做了很长时间,wa了好几次,主要是错在一些小细节上,比如第二个sort中我end本来是T+C,我错误写成T+N,所以编译器通过,但poj一直wa...所以一定要细心,耐心...此题主要注意的是一个team提交ac之后,可能还会提交,但不算惩罚时间;一题只能给第一次做对的对ac;还有就是一题没有ac之前wa都不计入总的惩罚时间。这里还用到了STL里的排序。添加头文件#include<algorithm> 并构造排序方法(sort()有两种形式,sort(begine, end, operate)和sort(begine, end)后者默认排序方式为从小到大)。
#include <iostream>#include<algorithm> using namespace std;const int maxn=1010;struct team{int id,ac,t; bool s[21]; //是否解决某题 int wa[21]; //某题错误次数 };struct node { int c,p,t,r; //c为队号,p为题号,t为提交时间,r为运行结果 };bool cmp_t(const node &a,const node &b) //自己定义比较时间大小,排序 { return a.t<b.t; };bool cmp_rank(const team &a,const team &b) //大小,排序 { if(a.ac!=b.ac)return a.ac>b.ac;if(a.t!=b.t)return a.t<b.t;return a.id<b.id; };int main(){int C,N;team T[maxn]; node n[maxn];memset(T,0,sizeof(T)); memset(n,0,sizeof(n)); cin>>C>>N; //C为队伍数,N为运行数 for(int i=0;i<N;i++) cin>>n[i].c>>n[i].p>>n[i].t>>n[i].r; for(int i=0;i<C;i++) T[i].id=i+1; sort(n,n+N,cmp_t); /*node a; //提交时间排序 for(int i=0;i<N-1;i++) for(int j=i+1;j<N;j++) if(n[i].t<n[j].t) { a=n[i]; n[i]=n[j]; n[j]=a; } */ for(int i=0;i<N;i++){int x=n[i].c-1,y=n[i].p-1;if(T[x].s[y]) //如果某队之前该题已经做对,则跳过 continue;if(n[i].r){ T[x].ac++; T[x].t+=T[x].wa[y]*1200+n[i].t;T[x].s[y]=1;}else T[x].wa[y]++;} sort(T,T+C,cmp_rank); /*team b; //排序 for(int i=0;i<C-1;i++) for(int j=i+1;j<C;j++) if(T[i].ac<T[j].ac||(T[i].ac==T[j].ac&&T[i].t>T[j].t)) { b=T[i]; T[i]=T[j]; T[j]=b; }*/ for(int i=0;i<C-1;i++) cout<<T[i].id<<' '; cout<<T[C-1].id<<endl;}
- ACM Rank Table(poj 2397)
- ACM Rank Table POJ
- poj 2379 ACM Rank Table
- poj 2379 ACM Rank Table
- [POJ] 2379 -> ACM Rank Table
- poj 2379 ACM Rank Table
- POJ 2379 ACM Rank Table(水~)
- ACM Rank Table
- POj 2379 ACM Rank Table
- (STL自带的排序功能7.1.3)POJ 2379 ACM Rank Table(结构体的排序、初始化)
- ACM-STEP Rank
- poj 2153 Rank List
- poj 2153 Rank List
- POJ 2153 Rank List
- poj 2153 Rank List
- Poj 2153 Rank List
- POJ 2135 Rank List
- hdu 5096 ACM Rank(treap)
- 修改shell界面回滚缓冲区大小
- 关于char, wchar_t, TCHAR, _T(),L,宏 _T、TEXT,_TEXT、L
- 程序员面试、算法研究、编程艺术、红黑树、数据挖掘5大系列集锦
- DEDE文章列表获取单篇文章TAGS解决方法
- Parcel 和 Parcelable
- ACM Rank Table(poj 2397)
- NYOJ 264题 国王的魔镜
- NS3中日志信息输出到文件
- Cities
- ASP.NET MVC3.0中同一View如何返回多个Model或数据集
- 【AWK】Scanning all Elements of an Array--每日一译2013-02-05
- SVN中的Import
- 实现设计模式:工厂模式
- Android 内存优化