#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct student{
char id[15] ; //考生学号
int sorce; //考生分数
int local_number; //考场号
int local_rank; //考场排名
}stu[1000];
bool cmp(student a,student b){
if(a.sorce!=b.sorce ) return a.sorce >b.sorce ;
else return strcmp(a.id,b.id)<0;
}
int main(){
int k,i,j,n,Acw=0,temp=1;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&k);
for(j=0;j<k;j++)
{
scanf("%s %d",&stu[Acw].id,&stu[Acw].sorce );
stu[Acw].local_number=i;
Acw++;
}
sort(stu+Acw-k,stu+Acw,cmp);
stu[Acw-k].local_rank=1;
for(j=Acw-k+1;j<Acw;j++){
if(stu[j-1].sorce!=stu[j].sorce )
{
stu[j].local_rank=j-(Acw-k)+1;
}
else {
stu[j].local_rank=stu[j-1].local_rank;
}
}
/* 测试考场内排名用模块 *//*
for(j=0;j<k;j++)
{
printf("%s %d %d %d\n",stu[j].id,stu[j].sorce,stu[j].local_number,stu[j].local_rank);
}
*/
}
sort(stu,stu+Acw,cmp);
printf("%d\n",Acw);int rank_all=1;
for(i=0;i<Acw;i++)
{ if(i>0 && stu[i].sorce !=stu[i-1].sorce ) rank_all=i+1;
printf("%s %d %d %d\n",stu[i].id ,rank_all,stu[i].local_number,stu[i].local_rank);
}
//唱晚 我还是忘不掉你。
return 0 ;
}
Sample Input:
2
5
1234567890001 95
1234567890005 100
1234567890003 95
1234567890002 77
1234567890004 85
4
1234567890013 65
1234567890011 25
1234567890014 100
1234567890012 85
Sample Output:
9
1234567890005 1 1 1
1234567890014 1 2 1
1234567890001 3 1 2
1234567890003 3 1 2
1234567890004 5 1 4
1234567890012 5 2 2
1234567890002 7 1 5
1234567890013 8 2 3
1234567890011 9 2 4