ACM Rank Table
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 5962 | Accepted: 1523 |
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:
- 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.
Output
Output must contain C integers -- team numbers sorted by rank.
Sample Input
3 3 1 2 3000 0 1 2 3100 1 2 1 4200 1
Sample Output
2 1 3
Source
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn = 1010;
struct judge{
int c;
int p;
int r;
int t;
}a[maxn];
struct team{
int id;
int ac;
int t;
int p[25];
int sol[25];
}t[maxn];
int com_t(struct judge a,struct judge b){
return a.t < b.t;
}
int com_ac(struct team a , struct 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(void ){
int C,N;
while(scanf("%d%d",&C,&N)!=EOF){
memset(a,0,sizeof(a));
memset(t,0,sizeof(t));
for(int i = 1 ; i <= C ; ++i){
t[i].id = i;
}
for(int i = 1 ; i <= N ; ++i){
scanf("%d%d%d%d",&a[i].c,&a[i].p,&a[i].t,&a[i].r);
}
sort(a+1,a+1+N,com_t);
for(int i = 1 ; i <= N ; ++i){
int x = a[i].c;
int y = a[i].p;
if(t[x].sol[y]){
continue;
}
if(a[i].r){
t[x].ac++;
t[x].t += t[x].p[y]*1200 + a[i].t;
t[x].sol[y] = true;
}else{
t[x].p[y]++;
}
}
sort(t+1,t+1+C,com_ac);
for(int i = 1 ; i < C ; ++i){
printf("%d ",t[i].id);
}
printf("%d\n",t[C].id);
}
return 0;
}
1.有些team会在一道题AC了之后还提交,这个时候只需要算第一次ac的时间以及这之前的wa,之后的全部忽略。
2.如果一道题没有ac,那么在计算时间时不应该加上它的wa带来的惩罚。
3.先按做题最多的排,如相等,再按提交时间最少的排,如相等,再按队号最小的排。
4.给的数据,提交的时间不是按顺序排的。
int com_ac(struct team a , struct 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;
}
上面的代码是多个优先级比较的比较函数!