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:

3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40

Sample Output:

SC3021234 CS301133

还是一道很简单的题,但是值得纪念的是第一次提交就全对了!
用的是map然后重载运算符分别求最大和最小。
bool operator <(const data t1,const data t2){return ...}
#include <iostream>
#include <map>
#include <string>
using namespace std; typedef struct data{
int h,m,s;
}data; bool operator<(const data &t1,const data &t2){ return (t1.h<t2.h) || (t1.h==t2.h&&t1.m<t2.m) || (t1.h==t2.h&&t1.m==t2.m&&t1.s<t2.s); } map<data,string> in;
map<data,string> out; data intime[];
data outtime[]; int main()
{
int n;
cin>>n;
int i=;
while(n--){
string Itime,Otime,ID;
cin>>ID>>Itime>>Otime;
data I,O;
I.h=(Itime[]-)*+(Itime[]-);
I.m=(Itime[]-)*+(Itime[]-);
I.s=(Itime[]-)*+(Itime[]-);
O.h=(Otime[]-)*+(Otime[]-);
O.m=(Otime[]-)*+(Otime[]-);
O.s=(Otime[]-)*+(Otime[]-);
in[I]=ID;
out[O]=ID;
intime[i]=I;
outtime[i]=O;
i++;
}
data min;
min.h=,min.m=,min.s=;
for(int j=;j<i;j++){
if(intime[j]<min){
min.h=intime[j].h;
min.m=intime[j].m;
min.s=intime[j].s;
}
}
cout<<in[min];
data max;
max.h=,max.m=,max.s=;
for(int j=;j<i;j++){
if(max<outtime[j]){
max.h=outtime[j].h;
max.m=outtime[j].m;
max.s=outtime[j].s;
}
}
cout<<" "<<out[max];
return ;
}

1006. Sign In and Sign Out (25)的更多相关文章

  1. PAT 甲级 1006 Sign In and Sign Out (25)(25 分)

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  2. 1006 Sign In and Sign Out (25 分)

    1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the co ...

  3. PAT甲 1006. Sign In and Sign Out (25) 2016-09-09 22:55 43人阅读 评论(0) 收藏

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  4. 1006 Sign In and Sign Out (25)(25 分)思路:普通的时间比较题。。。

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  5. pat 1006 Sign In and Sign Out(25 分)

    1006 Sign In and Sign Out(25 分) At the beginning of every day, the first person who signs in the com ...

  6. PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) 凌宸1642 题目描述: At the beginning of ever ...

  7. pat1006. Sign In and Sign Out (25)

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

  8. PTA (Advanced Level) 1006 Sign In and Sign Out

    Sign In and Sign Out At the beginning of every day, the first person who signs in the computer room ...

  9. PAT甲级——1006 Sign In and Sign Out

    PATA1006 Sign In and Sign Out At the beginning of every day, the first person who signs in the compu ...

  10. PAT1006:Sign In and Sign Out

    1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...

随机推荐

  1. Response.End抛出ThreadAbortException 异常

    最近在写程序过程中遇到了一个匪夷所思的错误:Response.End()方法抛出了ThreadAbortException异常,我的代码如下: public void doResponse(){ st ...

  2. Android Activity 切换动画(非原创)

    在Android开发过程中,经常会碰到Activity之间的切换效果的问题,下面介绍一下如何实现左右滑动的切换效果,首先了解一下Activity切换的实现,从Android2.0开始在Activity ...

  3. 0-js判断电脑或手机登录

    <script type="text/javascript"> try{ if(/Android|webOS|iPhone|iPod|BlackBerry/i.test ...

  4. rdesktop的使用

    整个地球都知道rdesktop,有了它,我们可以从Solaris或者Linux使用Windows,当然Windows要开启Windows Terminal Service.虽然也有基于GTK+的tsc ...

  5. Base64 的那些事儿

    一.Base64是什么? Base64是一种编码的格式.是将信息流(字节流)按照一定的规范,重新组合,显示出完全不相关内容的编码格式. ps.定义是我自己总结的,我觉得对于知识的定义,只要简洁,不错误 ...

  6. Python快速建站系列-Part.Five.3-个人主页及资料页面

    |版权声明:本文为博主原创文章,未经博主允许不得转载. 第五部分最后一节,完成个人主页里资料页面的个人资料的展示和修改功能,不过毕竟功能比较少,个人资料其实只有昵称一项,手动滑稽. 一如既往先写出来u ...

  7. [LeeCode]Power of Two

    Given an integer, write a function to determine if it is a power of two. My initial code: class Solu ...

  8. php用正则检测某字段开头是否为字母

    //判断数组都已字段的开头是否为字母 $data=array();  for($i=0;$i<$length;$i++){ //是,则把数组重新取出赋值if (preg_match(" ...

  9. Android: 实例解析Activity生命周期

    Activity生命周期图: 下面以一个实例来解析,实例APP运行,进入MainActivity, 点击Send Button以后进入MessgaeActivity 当第一次运行App,进入MainA ...

  10. BlogEngine2.9模仿yahoo滚动新闻Widget

    widget.ascx <%@ Control Language="C#" AutoEventWireup="true" CodeFile="w ...