#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct Student{
char id[15];
int score;
int local_num;
int local_rank;
}stu[30010];
bool cmp(Student a,Student b){
if(a.score!=b.score){
return a.score>b.score;
}else return strcmp(a.id,b.id)<0;
}
int main()
{
int n;
cin>>n;
int num=0;
for(int j=0;j<n;j++){
int k;
cin>>k;
for(int i=0;i<k;i++){
scanf("%s %d",&stu[num].id,&stu[num].score);
stu[num].local_num=j+1;
num++;
}
sort(stu+num-k,stu+num,cmp);
stu[num-k].local_rank=1;
for(int i=num-k+1;i<num;i++){
if(stu[i].score!=stu[i-1].score) stu[i].local_rank=i+1-(num-k);
else stu[i].local_rank=stu[i-1].local_rank;
}
}
sort(stu,stu+num,cmp);
cout<<num<<endl;
int r=1;
for(int i=0;i<num;i++){
if(i>0 && stu[i].score!=stu[i-1].score)
r=i+1;
printf("%s %d %d %d\n",stu[i].id,r,stu[i].local_num,stu[i].local_rank);
}
return 0;
}
【PAT】1025. PAT Ranking
最新推荐文章于 2024-05-22 12:35:49 发布