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. Linux命令集合

    系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS ...

  2. Infinite V2 Release Note

    游戏地址 PLAY 玩法说明 - WASD 控制角色移动 - 按下J键 进入攻击模式(WASD 可以继续移动) 更新内容 - 完成角色锁定目标后边移动边攻击 开发心得 状态机的设计 最初的设计很乱, ...

  3. MFC Picture控件加载图片

    CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE); CBitmap bitmap; bitmap.LoadBitmapW(IDB_BITMAP2); ...

  4. Linux启用和配置Java

    Firefox 在安装 Java 平台时,Java 插件文件将作为该安装的一部分包含在内.要在 Firefox 中使用 Java,您需要从该发行版中的插件文件手动创建符号链接指向 Firefox 预期 ...

  5. c# 利用动态库DllImport("kernel32")读写ini文件(提供Dmo下载)

    c# 利用动态库DllImport("kernel32")读写ini文件 自从读了设计模式,真的会改变一个程序员的习惯.我觉得嘛,经验也可以从一个人的习惯看得出来,看他的代码编写习 ...

  6. mysql 表迁移

    http://blog.csdn.net/evan_endian/article/details/8652528  mysql中把一个表的数据批量导入另一个表中   不管是在网站开发还是在应用程序开发 ...

  7. 从oracle数据库中导出excel问题导致乱码的问题

    使用plsqldev工具将oracle的查询结果导出为excel,结果可以成功导出,但是使用libreoffice进行查看时,有好多记录都是空的. 使用python进行导出(openpyxl模块进行e ...

  8. android 布局学习

    各种layout用到的一些重要属性 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 android:layout_centerVertic ...

  9. 二十五、JDK1.5新特性---枚举

    与上篇文章介绍的相同,本文也是介绍jdk 1.5出现的新特性,本文将介绍枚举的相关用法. 在jdk 1.5 之前.Java可以有两种方式定义新类型:类和接口.对于大部分面向对象来说.这两种方法看起来似 ...

  10. MySQL MMM 双主在Failover时挂起

    两台MySQL服务器,版本Percona 5.5.35,配置双主,装在Centos 6.4下 Master1  db1,172.21.120.160(真实IP),172.21.120.173(Writ ...