浙大计算机研究生复试上机考试-2005年
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct zhengjian { char num[20]; int shour; int sminute; int ssencend; int ehour; int eminute; int esencend; }a[1100]; bool cmp1(zhengjian a,zhengjian b) { if(a.shour != b.shour) return a.shour<b.shour; else if(a.sminute!=b.sminute) return a.sminute < b.sminute; else if(a.ssencend!=b.ssencend) return a.ssencend < b.ssencend; return a.num < b.num; } bool cmp2(zhengjian a,zhengjian b) { if(a.ehour != b.ehour) return a.ehour > b.ehour; else if(a.eminute!=b.eminute) return a.eminute > b.eminute; else if(a.esencend!=b.esencend) return a.esencend > b.esencend; return a.num < b.num; } int main() { int N,M; while(~scanf("%d",&N)) { for(int i = 1; i <= N; i++) { scanf("%d",&M); memset(a,0,sizeof(a)); for(int j = 0; j < M; j++) { getchar(); scanf("%s%d:%d:%d %d:%d:%d",a[j].num,&a[j].shour,&a[j].sminute,&a[j].ssencend,&a[j].ehour,&a[j].eminute,&a[j].esencend); } sort(a,a+M,cmp1); printf("%s ",a[0].num); sort(a,a+M,cmp2); printf("%s\n",a[0].num); } } return 0; }