http://ac.jobdu.com/problem.php?pid=1130
参考了 http://www.cnblogs.com/jasonJie/p/5740646.html
#include <stdio.h>
#include <cmath>
#include <algorithm>
typedef struct date{
int year,month,day;
friend bool operator < (struct date a, struct date b){
if(a.year != b.year){
return a.year < b.year;
}else if(a.month != b.month){
return a.month < b.month;
}else{
return a.day < b.day;
}
}
friend bool operator != (struct date a, struct date b ){
return !(a.year == b.year && a.month == b.month && a.day == b.day);
}
}Date;
typedef struct time{
int hour,minute,sec,mil_sec;
bool friend operator != (struct time a, struct time b){
return !(a.hour == b.hour && a.minute == b.minute
&& a.sec == b.sec && a.mil_sec == b.mil_sec);
}
bool friend operator < (struct time a, struct time b){
if(a.hour != b.hour){
return a.hour < b.hour;
}else if(a.minute != b.minute){
return a.minute < b.minute;
}else if(a.sec != b.sec) {
return a.sec < b.sec;
}else{
return a.mil_sec < b.mil_sec;
}
}
}Time;
typedef struct record{
int id;
char pid[11];
Date date;
Time time;
double task_time;
bool friend operator < (struct record a, struct record b){
if(fabs(a.task_time - b.task_time)>1e-5 ){
return a.task_time < b.task_time;
}else if(a.date != b.date){
return a.date < b.date;
}else{
return a.time < b.time;
}
}
}Record;
int main(){
//freopen("in/1130.in","r",stdin);
Record r[10001];
char lines[10001][320];
int n=0;
while(gets(lines[n])!=0){
sscanf(lines[n],"%s %d-%d-%d %d:%d:%d,%d %lf(s)\n",r[n].pid,
&r[n].date.year,&r[n].date.month,&r[n].date.day,
&r[n].time.hour,&r[n].time.minute,&r[n].time.sec,&r[n].time.mil_sec,
&r[n].task_time);
r[n].id = n;
n++;
}
std::sort(r,r+n);
for (int i = 0; i < n; ++i) {
//printf("%s %d-%d-%d %d:%d:%d,%d %lf(s)\n",r[n].pid,
//r[n].date.year,r[n].date.month,r[n].date.day,
//r[n].time.hour,r[n].time.minute,r[n].time.sec,r[n].time.mil_sec,
//r[n].task_time);
puts(lines[r[i].id]);
}
}