能用vector尽量不用数组
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
struct student{
long long int name;
int mark;
int type;
int level1;
int level2;
};
bool cmp(student a,student b){
if(a.mark!=b.mark)
return a.mark>b.mark;
else
return a.name<b.name;
}
int main(){
int n;
scanf("%d",&n);
vector<student> st;
for(int i=1;i<=n;i++){
int num;
scanf("%d",&num);
vector<student> v(num);
for(int j=0;j<num;j++){
scanf("%lld %d",&v[j].name,&v[j].mark);
v[j].type=i;
}
sort(v.begin(),v.end(),cmp);
v[0].level2=1;
st.push_back(v[0]);
for(int j=1;j<num;j++){
if(v[j].mark==v[j-1].mark)
v[j].level2=v[j-1].level2;
else
v[j].level2=j+1;
st.push_back(v[j]);
}
}
sort(st.begin(),st.end(),cmp);
st[0].level1=1;
for(int i=1;i<st.size();i++){
if(st[i].mark==st[i-1].mark)
st[i].level1=st[i-1].level1;
else
st[i].level1=i+1;
//printf("%d\n",st[i].level1);
}
printf("%d\n",st.size());
for(int i=0;i<st.size();i++)
printf("%013lld %d %d %d\n",st[i].name,st[i].level1,st[i].type,st[i].level2);
return 0;
}