原題:
Think the contest score boards are wrong? Here’s your chance to come up with the right rankings.Contestants are ranked first by the number of problems solved (the more the better), then by decreasing amounts of penalty time. If two or more contestants are tied in both problems solved and penalty time, they are displayed in order of increasing team numbers.
A problem is considered solved by a contestant if any of the submissions for that problem was judged correct. Penalty time is computed as the number of minutes it took for the first correct submission for a problem to be received plus 20 minutes for each incorrect submission received prior to the correct solution. Unsolved problems incur no time penalties.
Input
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
Input consists of a snapshot of the judging queue, containing entries from some or all of contestants 1 through 100 solving problems 1 through 9. Each line of input will consist of three numbers and a letter in the format
contestant problem time L where L can be ‘C’, ‘I’, ‘R’, ‘U’ or ‘E’. These stand for Correct, Incorrect, clarification Request, Unjudged
and Erroneous submission. The last three cases do not affect scoring.
Lines of input are in the order in which submissions were received.
Output
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
Output will consist of a scoreboard sorted as previously described. Each line of output will contain a contestant number, the number of problems solved by the contestant and the time penalty accumulated by the contestant. Since not all of contestants 1-100 are actually participating, display only the contestants that have made a submission.
Sample Input
1
1 2 10 I
3 1 11 C
1 2 19 R
1 2 21 C
1 1 25 C
Sample Output
1 2 66
中文:
ACM的比賽排名標準。
來自lucky 貓
有想過程式設計比賽的計分版是錯的嗎。現在你有機會來瞭解一下正確的排名方式了。
參賽者首先根據解出題數來排名,越多的越好。若是解出的題數一樣則按照處罰時間(penalty time)來排名,越小的越好。若是解出題數及處罰時間都一樣,則按照參賽者的編號由小到大來排。
某參賽者被視為解出某一個問題乃由於裁判裁定其某次上傳的答案為正確(也就是Accept啦)。而各參賽者處罰時間的計算方式為:他各題的處罰時間的總和。而某人某題處罰時間的計算方式為:某人某題被判為正確時所花的時間(單位:分鐘)加上該題之前被判為錯誤的上傳次數*20分鐘。例如某人某題在第100分鐘時上傳答案且裁判判為正確,且在這之前此題他曾送出3次錯誤答案。所以他此題的處罰時間為100+3*20=160。請注意:未解出的問題不列入處罰時間,不論他這題送了幾次錯誤答案。另外,某一題的處罰時間只算到該題第一次被判為正確。若某人某題已解出後仍繼續上傳該題答案,則裁判將忽略那些答案。
Input
輸入的第一列有一個正整數,代表以下有多少組測試資料。每組測試資料的的內容為裁判收到各次上傳資料及判定的紀錄,包含參賽者編號、題號、上傳時間(按時間排序)及裁判結果,以下列的格式呈現:
contestant problem time L
其中contestant為參賽者編號(1~100),problem為題目編號(1~9),time為上傳的時間(從比賽開始算起的分鐘數),L為裁判結果,分為C、I、R、U、E。C代表正確,I代表不正確,後三者不影響分數。
輸入的第一列與第一組測試資料之間,以及各組測試資料之間均有一空白列,請參考Sample Input。
Output
每組測試資料按上面題目所述的方法輸出排名,包括參賽者編號、解出的題數及處罰時間。由於並非1~100號所有的參賽者均有真正出席參賽,所以只需列出有上傳答案的參賽者。
測試資料間亦請空一列,請參考Sample Output。
Sample Input
2
1 2 10 I
3 1 11 C
1 2 19 R
1 2 21 C
1 1 25 C
1 2 10 I
3 1 11 C
1 2 19 R
1 2 21 C
1 1 25 C
6 1 50 I
7 1 60 E
Sample Output
1 2 66
3 1 11
1 2 66
3 1 11
6 0 0
7 0 0
#include <bits/stdc++.h>#pragma warning(disable:4996)using namespace std;const int inf=9999999;struct node{ int pro[10]; bool ac[10]; int mark; int id,num; node() { for(int i=0;i<10;i++) { pro[i]=0; ac[i]=false; } mark=0; id=-1; num=0; }};map<int,node> mi;int cmp(const node &a,const node &b){ if(a.num!=b.num) return a.num>b.num; else return a.mark<b.mark;}int main(){// ios::sync_with_stdio(false); char s[101]; int t; scanf("%d",&t); getchar(); getchar(); while(t--) { int a,b,c,k; char d; mi.clear(); while(gets(s)&&s[0]) { sscanf(s,"%d %d %d %c",&a,&b,&c,&d); node p; p=mi[a]; p.id=a; mi[a].id=a; if(d=='R'||d=='U'||d=='E') continue; if(p.ac[b]) continue; if(d=='C') { p.ac[b]=1; p.mark+=c+p.pro[b]*20; p.num++; } else p.pro[b]++; mi[a]=p; // cout<<mi[a].id<<" "<<mi[a].num<<" "<<mi[a].mark<<endl; } vector<node> tmp; for(auto x:mi) tmp.push_back(x.second); sort(tmp.begin(),tmp.end(),cmp); for(int i=0;i<tmp.size();i++) { int id=tmp[i].id,num=tmp[i].num,mark=tmp[i].mark; printf("%d %d %d\n",id,num,mark); } if(t) printf("\n"); } return 0;}
解答:
被這道題的輸入方式給弄瘋了,直接類比即可。