2013-07-18 10:50:50Morris
[UVA] 790 - Head Judge Headache
Head Judge Headache
Head Judge Headache |
You are the Head Judge of the ACM Eastern European Regional Programming Contest. The master Judge computer has been infected by computer virus which has formated the hard disk.
Input
The first line of the input indicates the number of test cases, and it's followed by a blank line.For each dataset you have only the listing of submitted problems log formatted as follows:
(
25)
(A..G)
(h:mm)
(Y/N)
There's a blank line between datasets.
Output
Write a program to compute the final standing for each dataset by using the following rules:
- Teams are ranked according to the most problems solved.
- Teams who have solved the same number of problems are ranked by least total time.
- The total time is the sum of the time consumed for each problem solved.
- The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submital of the accepted run plus 20 minutes for each previously rejected run. Further submisions will be ignored.
- There is no time consumed for a problem that is not solved.
- Teams with equal score are assigned equal rank sorted by team number.
Print a blank line between datasets.
Sample Input
1 1 A 0:50 N 3 A 1:12 Y 2 B 1:19 N 1 A 1:20 Y 2 B 1:35 N 1 B 1:36 N 3 B 1:40 Y 3 C 1:41 N 4 A 1:40 Y
Sample Output
RANK TEAM PRO/SOLVED TIME 1 3 2 172 2 1 1 100 2 4 1 100 4 2
Miguel Revilla
2001-01-05
題目要模擬比賽時的 scoreboard,
但是給的順序可能沒有排序過,因此要自己排序一次。
可能會有很多時間點會相同,排序的原則題目沒有說清楚。
如果同一隊在同一時間同時有 N 或 Y,考慮先將 N 放前面。
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
struct E {
int team, pro, time;
bool operator<(const E &a) const {
if(pro != a.pro)
return pro > a.pro;
if(time != a.time)
return time < a.time;
return team < a.team;
}
};
struct info {
int team, pro, time, tr;
bool operator<(const info &a) const {
if(time != a.time)
return time < a.time;
return tr < a.tr;
}
};
int main() {
int testcase;
scanf("%d", &testcase);
while(getchar() != '\n');
while(getchar() != '\n');
char s[105], sp[105], sr[105];
int i, j, k;
while(testcase--) {
int board[50][50] = {};
int penalty[50] = {}, used[50] = {};
int ac[50] = {}, wa[50][50] = {};
info I[105];
E D[105];
int n = 0, mx = 0;
while(gets(s)) {
if(s[0] == '\0')
break;
int team, hh, mm;
sscanf(s, "%d %s %d:%d %s", &team, sp, &hh, &mm, sr);
mm = hh*60 + mm;
used[team] = 1;
sp[0] -= 'A';
I[n].team = team, I[n].pro = sp[0], I[n].time = mm;
I[n].tr = (sr[0] == 'Y');
mx = max(mx, team);
n++;
}
sort(I, I+n);
for(i = 0; i < n; i++) {
if(board[I[i].team][I[i].pro] == 1)
continue;
if(I[i].tr == 0) {
wa[I[i].team][I[i].pro]++;
continue;
}
board[I[i].team][I[i].pro] = 1;
ac[I[i].team]++, penalty[I[i].team] += I[i].time + 20*wa[I[i].team][I[i].pro];
}
n = 0;
for(i = 1; i <= mx; i++) {
D[n].pro = ac[i], D[n].team = i;
D[n].time = penalty[i];
n++;
}
sort(D, D+n);
puts("RANK TEAM PRO/SOLVED TIME");
int rank = 0;
for(i = 0; i < n; i++) {
if(i == 0 || D[i].pro != D[i-1].pro || (D[i].pro == D[i-1].pro && D[i].time != D[i-1].time))
rank = i+1;
if(D[i].pro)
printf("%4d %4d %4d %4d\n", rank, D[i].team, D[i].pro, D[i].time);
else
printf("%4d %4d\n", rank, D[i].team);
}
if(testcase) puts("");
}
return 0;
}