您的位置:首页 > 其它

HDU 1234 简单模拟题

2014-12-31 02:00 218 查看
题目很简单不多说了,我只是觉得这题目的输入方式还是很有特点的

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

struct People{
char name[20];
int h1 , h2 , m1 , m2 , s1 , s2;
}p[10005];

bool cmp1(const People &p1 , const People &p2){
if(p1.h1 == p2.h1 && p2.m1 == p1.m1) return p1.s1 < p2.s1;
else if(p1.h1 == p2.h1) return p1.m1 < p2.m1;
else return p1.h1 < p2.h1;
}

bool cmp2(const People &p1 , const People &p2){
if(p1.h2 == p2.h2 && p2.m2 == p1.m2) return p1.s2 > p2.s2;
else if(p1.h2 == p2.h2) return p1.m2 > p2.m2;
else return p1.h2 > p2.h2;
}

int main()
{
//  freopen("a.in" , "r" , stdin);
int T , n;
scanf("%d" , &T);
while(T--){
scanf("%d" , &n);
memset(p , 0 , sizeof(p));
for(int i = 1 ; i<=n ; i++){
scanf("%s%d:%d:%d%d:%d:%d" , p[i].name , &p[i].h1 , &p[i].m1 ,
&p[i].s1 , &p[i].h2 , &p[i].m2 , &p[i].s2);
// cout<<p[i].h1<<":"<<p[i].m1<<":"<<p[i].s1<<endl;
}
sort(p+1 , p+n+1 , cmp1);
printf("%s " , p[1].name);
sort(p+1 , p+n+1 , cmp2);
printf("%s\n" , p[1].name);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: