| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 
 | #include<bits/stdc++.h>
 using namespace std;
 
 struct student
 {
 char name[14];
 int chengji;
 int zuhao;
 int znpm;
 int ztpm;
 }stu[30003];
 
 bool cmp(student a,student b)
 {
 if(a.chengji!=b.chengji)
 return a.chengji>b.chengji;
 return strcmp(a.name,b.name)<0;
 }
 int main()
 {
 int i,n,j;int m,t,p;int sum;
 int temp,temp1;
 scanf("%d",&n);
 t=1;
 int arr[30003];
 arr[0]=0;
 int q;int sub=0;
 q=0;
 for(i=1;i<=n;i++)
 {
 scanf("%d",&m);
 arr[t++]=m;
 sub+=m;
 for(q;q<sub;q++)
 {
 scanf("%s %d",stu[q].name,&stu[q].chengji);
 stu[q].zuhao=i;
 stu[q].znpm=0;
 stu[q].ztpm=0;
 }
 }
 for(i=0;i<n;i++)
 {
 temp=arr[i];
 arr[i+1]+=temp;
 temp1=arr[i+1];
 sort(stu+temp,stu+temp1,cmp);
 p=1;
 for(j=temp;j<temp1;j++)
 {
 stu[j].znpm=p++;
 }
 for(j=temp;j<temp1;j++)
 {
 if(stu[j].chengji==stu[j+1].chengji)
 stu[j+1].znpm=stu[j].znpm;
 }
 }
 sort(stu,stu+sub,cmp);
 for(j=0;j<sub;j++)
 stu[j].ztpm=j+1;
 p=1;
 for(j=0;j<sub;j++)
 {
 if(stu[j].chengji==stu[j+1].chengji)
 stu[j+1].ztpm=stu[j].ztpm;
 }
 printf("%d\n",sub);
 for(j=0;j<sub;j++)
 {
 if(j!=sub-1)
 printf("%s %d %d %d\n",stu[j].name,stu[j].ztpm,stu[j].zuhao,stu[j].znpm);
 else
 printf("%s %d %d %d",stu[j].name,stu[j].ztpm,stu[j].zuhao,stu[j].znpm);
 }
 return 0;
 }
 
 |