#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct{
char rid[13];
int score;
int frank;
int lrank;
int location;
}testee;
vector<testee> list[300];
vector<testee> sumList;
//注意sort中使用的比较函数是bool,而且参数不是指针!
//int cmp(const void * a, const void * b){
// testee ta = * ( (testee *)a);
// testee tb = * ( (testee *)b);
bool cmp(testee ta, testee tb){
if(ta.score != tb.score){
return (ta.score > tb.score);
}else{
return (strcmp(ta.rid, tb.rid)<0);
}
}
int main(){
//freopen("in.txt","r",stdin);
int N;
scanf("%d",&N);
int i,j;
int count = 0;//testee总数
//并列排名
int locRank;
int currScore;
for(i=0; i<N; i++){
int K;
scanf("%d",&K);
count += K;
for(j=0; j<K; j++){
testee tmp;
scanf("%s %d",tmp.rid, &tmp.score);
tmp.location = i + 1;
list[i].push_back(tmp);
}
//location排序
sort(list[i].begin(), list[i].end(),cmp);
//location名次
locRank = 1;
currScore = list[i][0].score;
for(j=0; j<K; j++){
if(list[i][j].score < currScore){
list[i][j].lrank = j+1;
locRank = j+1;
currScore = list[i][j].score ;
}else if(list[i][j].score == currScore){
list[i][j].lrank = locRank;
}
}
}
//vectorappend使用insert
for(i=0; i<N; i++){
sumList.insert(sumList.end(),list[i].begin(), list[i].end());
}
printf("%d\n", sumList.size());
sort(sumList.begin(), sumList.end(),cmp);
locRank = 1;
currScore = sumList[0].score;
for(i=0; i<count; i++){
if(sumList[i].score < currScore){
sumList[i].frank = i+1;
locRank = i+1;
currScore = sumList[i].score ;
}else if(sumList[i].score == currScore){
sumList[i].frank = locRank;
}
}
for(j=0; j<count; j++){
printf("%s %d %d %d\n",sumList[j].rid, sumList[j].frank, sumList[j].location, sumList[j].lrank);
}
return 0;
}
一次A过,好感动oo>_<oo