#include<iostream> #include<algorithm> #include<string.h> using namespace std; struct worker { int id; char name[11]; int age; }; bool comp(worker lhs, worker rhs) { if (lhs.age < rhs.age) { return true; } else if (lhs.age == rhs.age && lhs.id < rhs.id) { return true; } else if (lhs.age == rhs.age && lhs.id == rhs.id && strcmp(lhs.name, rhs.name) <= 0) { return true; } else return false; } int main() { int n; worker w[1000]; while (scanf("%d", &n) != EOF) { int i; for (i = 0; i < n; i++) { scanf("%d%s%d", &w[i].id, w[i].name, &w[i].age); } sort(w, w + n, comp); if (n < 3) { for (i = 0; i < n; i++) { printf("%d %s %d\n", w[i].id, w[i].name, w[i].age); } } else { for (i = 0; i < 3; i++) { printf("%d %s %d\n", w[i].id, w[i].name, w[i].age); } } } }