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. PHP自带防SQL攻击函数区别

    为了防止SQL注入攻击,PHP自带一个功能可以对输入的字符串进行处理,可以在较底层对输入进行安全上的初步处理,也即Magic Quotes.(php.ini magic_quotes_gpc).如果m ...

  2. web 安全的前期准备哦

    学习web安全  需要的软件  和 基础 基础会在以后发出来  软件  在网上都可以下 首先   你要有一款虚拟机软件 虚拟系统通过生成现有操作系统的全新虚拟镜像,它具有真实windows系统完全一样 ...

  3. Create a SQL Server Database on a network shared drive

    (原文地址:http://blogs.msdn.com/b/varund/archive/2010/09/02/create-a-sql-server-database-on-a-network-sh ...

  4. Mount DVD on CentOS

    Mount DVD on CentOS need to mount CD/DVD on CentOS Temporarily or Permanently? Here’s the Process Us ...

  5. SSAS动态添加分区 (转载)

    一.动态分区的好处就不说了,随着时间的推移,不可能一个度量值组都放在一个分区中,处理速度非常慢,如何动态添加分区,如何动态处理分区,成为了很多新手BI工程师一个头痛的问题,废话不多说,分享一下我的经验 ...

  6. JavaScript语言精粹读书笔记 - JavaScript函数

    JavaScript是披着C族语言外衣的LISP,除了词法上与C族语言相似以外,其他几乎没有相似之处. JavaScript 函数: 函数包含一组语句,他们是JavaScript的基础模块单元,用于代 ...

  7. ASP.NET 发布到IIS后支撑woff 的解决方案

    <system.webServer>    <staticContent>        <remove fileExtension=".woff" ...

  8. treeview所有节点递归解法(转+说明)或者说递归的实际应用

    public void PrintTreeViewNode(TreeNodeCollection node) { foreach (TreeNode n in node) { Response.Wri ...

  9. hadoop是什么

    Hadoop一直是我想学习的技术,正巧最近项目组要做电子商城,我就开始研究Hadoop,虽然最后鉴定Hadoop不适用我们的项目,但是我会继续研究下去,技多不压身. <Hadoop基础教程> ...

  10. Logstash学习-配置语法

    区段(section) Logstash 用{}来定义区域.区域内可以包括插件区域定义,你可以在一个区域定义多个插件,插件区域内则可以定义键值对设置. 数据类型 Logstash支持少量的数据值类型: ...