1006. Sign In and Sign Out (25)

来源:互联网 发布:师洋淘宝直播还骂人 编辑:程序博客网 时间:2024/06/07 14:54

At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find the ones who have unlocked and locked the door on that day.

Input Specification:

Each input file contains one test case. Each case contains the records for one day. The case starts with a positive integer M, which is the total number of records, followed by M lines, each in the format:

ID_number Sign_in_time Sign_out_time

where times are given in the format HH:MM:SS, and ID number is a string with no more than 15 characters.

Output Specification:

For each test case, output in one line the ID numbers of the persons who have unlocked and locked the door on that day. The two ID numbers must be separated by one space.

Note: It is guaranteed that the records are consistent. That is, the sign in time must be earlier than the sign out time for each person, and there are no two persons sign in or out at the same moment.

Sample Input:
3CS301111 15:30:28 17:00:10SC3021234 08:00:00 11:25:25CS301133 21:45:00 21:58:40
Sample Output:
SC3021234 CS301133
#include<iostream>#include<cstring>#include<cstdio>#include<queue>#include<stack>#include<algorithm>#include<cmath>using namespace std;typedef struct node{char name[200];int h,m,s;int h1,m1,s1;}node; bool cmp(node n1,node n2){if(n1.h==n2.h){if(n1.s==n2.s){return n1.s<n2.s;}else{return n1.m<n2.m;}}elsereturn n1.h<n2.h;}bool cmp1(node n1,node n2){if(n1.h1==n2.h1){if(n1.s1==n2.s1){return n1.s1>n2.s1;}else{return n1.m1>n2.m1;}}elsereturn n1.h1>n2.h1;}int main(){node n1[1000];int m;cin>>m;for(int i=0;i<m;i++){cin>>n1[i].name;scanf("%d:%d:%d %d:%d:%d",&n1[i].h,&n1[i].m,&n1[i].s,&n1[i].h1,&n1[i].m1,&n1[i].s1);}sort(n1,n1+m,cmp);cout<<n1[0].name<<" ";sort(n1,n1+m,cmp1);cout<<n1[0].name;return 0;}





原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 扣扣邮箱里的邮件过期了怎么办 一体机的管理员账号被删除了怎么办 手机里的邮箱重要吗删除了怎么办 华为荣耀10账号邮箱忘记了怎么办 大陆微信号在台湾登录不上怎么办 威纶触摸屏被禁止到反编译了怎么办 微信公众号邮箱被占用怎么办 京东绑定的手机号不用了怎么办 绑定微信的手机号不用了怎么办 绑定支付宝的手机号不用了怎么办 百度账号手机号换了密码忘了怎么办 换手机好了华为账号密码忘了怎么办 苹果手机忘了id账号和密码怎么办 金立手机账号密码忘了怎么办 乐视手机账号密码忘了怎么办 企业邮箱发出去邮件撤不回来怎么办 餐厅加热保温设备零线带电怎么办 小米手机不小心把照片删了怎么办 华为手机不小心把照片删了怎么办 网易邮箱被改成别人的姓名怎么办 苹果手机忘记id密码和邮箱怎么办 163邮箱下载的附件没有了怎么办 小米自带浏览器打开网页太慢怎么办 再歪一点授权码忘记了怎么办 注册支付宝的手机号不用了怎么办 手机号被别人注册了支付宝怎么办 支付宝账号密码都忘了怎么办 申请微信公众号邮箱被占用怎么办 邮箱注册微博需要手机验证怎么办 苹果手机的ad码忘记了怎么办 苹果手机酷狗音乐没有声音怎么办 在手机屏上不能缷载软件怎么办? 手机酷狗音乐下载歌曲要钱怎么办 酷狗下载歌曲后歌词不见了怎么办 手机酷我音乐缓冲文件损坏怎么办 苹果手机音乐里的歌删掉了怎么办 上课学生把粉笔擦藏起来了怎么办 手机没法解压10g压缩包怎么办 苹果id被锁邮箱也忘记密码怎么办 手机号注册的微信忘记密码怎么办 qq号注册微信忘记密码怎么办