提交时间:2026-01-04 14:43:03

运行 ID: 79783

#include <iostream> #include <vector> #include <algorithm> #include <string> struct Student { std::string name; int year, month, day; }; bool compare(const Student& a, const Student& b) { if (a.year != b.year) return a.year < b.year; if (a.month != b.month) return a.month < b.month; return a.day < b.day; } int main() { int n; std::cin >> n; std::vector<Student> students(n); for (int i = 0; i < n; ++i) { std::cin >> students[i].name >> students[i].year >> students[i].month >> students[i].day; } std::sort(students.begin(), students.end(), compare); for (int i = n - 1; i >= 0; --i) { std::cout << students[i].name << std::endl; } return 0; }