#include<iostream> #include<algorithm> using namespace std; class stu{public: char *name; int y,m,d; double is; stu(){name=new char[20];} }input[100]; int n,month[]={31,30,31,30,31,30,31,31,30,31,30,31}; bool compare(const stu &a,const stu &b){ if(a.y==b.y){ int temp0=a.m*month[a.m-1]+a.d; int temp1=b.m*month[a.m-1]+b.d; if(temp1!=temp0) return temp0<temp1; return a.is>b.is; }return a.y<b.y; } int main(){ int i; cin>>n; for(i=0;i<n;i++){ cin >>input[i].name >>input[i].y >>input[i].m >>input[i].d; input[i].is=i; } stable_sort(input,input+n,compare); for(i=0;i<n;i++){ cout<<input[i].name<<endl; } return 0; }
https://www.luogu.com.cn/problem/P1104