#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
struct node
{
char id[20];
int loc_num;
int score;
int final_rank;
int local_rank;
}T[30005];
bool cmp(node a,node b)
{
if(a.score!=b.score)
return a.score > b.score;
else
return strcmp(a.id,b.id)<0;//小->大
}
int main()
{
// freopen("in.txt","r",stdin);
int N,num=0;
scanf("%d",&N);
for(int i=1;i<=N;i++)
{
int k;
scanf("%d",&k);
for(int j=0;j<k;j++)
{
scanf("%s %d",T[num].id,&T[num].score);
T[num].loc_num = i;
num++;
}
sort(T+num-k,T+num-k+k,cmp);
T[num-k].local_rank=1;
for(int j=0+num-k+1;j<k+num-k+1;j++)
{
if(T[j].score==T[j-1].score)
{
T[j].local_rank=T[j-1].local_rank;
}
else
{
T[j].local_rank=j-(num-k)+1;
}
}
}
sort(T,T+num,cmp);
T[0].final_rank=1;
for(int i=1;i<num;i++)
{
if(T[i].score==T[i-1].score)
T[i].final_rank=T[i-1].final_rank;
else
T[i].final_rank=i+1;
}
printf("%d\n",num);
for(int i=0;i<num;i++)
printf("%s %d %d %d\n",T[i].id,T[i].final_rank,T[i].loc_num,T[i].local_rank);
return 0;
}
1025. PAT Ranking (25)
最新推荐文章于 2018-01-27 12:01:57 发布