#include<bits/stdc++.h>
using namespace std;
int n;
struct student{
int years,months,days,id;
char name[20];
};
student a[110];
bool operator >(student s1,student s2){
if(s1.years != s2.years) return s1.years > s2.years;
if(s1.months != s2.months) return s1.months > s2.months;
if(s1.days != s2.days) return s1.days > s2.days;
return s1.id > s2.id;
}
bool operator <(student s1,student s2){
if(s1.years != s2.years) return s1.years < s2.years;
if(s1.months != s2.months) return s1.months < s2.months;
if(s1.days != s2.days) return s1.days < s2.days;
return s1.id < s2.id;
}
void maopao(student *c,int n){
for(int i = 1;i <= n - 1;i ++){
bool b = true;
for(int j = 1;j <= n - i + 1;j ++){
if(*(c + j) < *(c + j - 1)){
swap(*(c + j),*(c + j - 1));
b = false;
}
}
if(b){
break;
}
}
}
int main(){
cin>>n;
for(int i = 1;i <= n;i ++){
cin>>a[i].name>>a[i].years>>a[i].months>>a[i].days;
a[i].id = i;
}
maopao(&a[0],n);
for(int i = 1;i <= n;i ++){
cout<<a[i].name<<endl;
}
return 0;
}
记录