其他分享
首页 > 其他分享> > P1104 生日

P1104 生日

作者:互联网

// Problem: P1104 生日
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1104
// Memory Limit: 128 MB
// Time Limit: 1000 ms
// User: Pannnn

#include <bits/stdc++.h>

using namespace std;

struct Stu {
    string name;
    int y;
    int m;
    int d;
    int id;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<Stu> info(n);
    
    for (int i = 0; i < n; ++i) {
        cin >> info[i].name >> info[i].y >> info[i].m >> info[i].d;
        info[i].id = i;
    }
    
    sort(info.begin(), info.end(), [](const Stu &s1, const Stu &s2) -> bool {
        if (s1.y != s2.y) {
            return s1.y < s2.y;
        } else if (s1.m != s2.m) {
            return s1.m < s2.m;
        } else if (s1.d != s2.d) {
            return s1.d < s2.d;
        } else {
            return s1.id > s2.id;
        }
    });
    
    for (int i = 0; i < n; ++i) {
        cout << info[i].name << endl;
    }
    return 0;
}

标签:info,P1104,return,int,s2,s1,生日,id
来源: https://www.cnblogs.com/pannnn/p/15855172.html