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

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
#include <iostream>
#include <cstring>
#include <cstdio>
#include<map>
#include<stack>
using namespace std;
struct person{
string id;
string start;
string ends;
}p[];
int main()
{ freopen("1.txt","r",stdin);
int n;
cin>>n;
for(int i=;i<n;i++){
cin>>p[i].id>>p[i].start>>p[i].ends;
}
int s=,e=;
string ss=p[].start,se=p[].ends;
for(int i=;i<n;i++){
if(p[i].start<ss){
ss=p[i].start;
s=i;
}
if(p[i].ends>se){//这里se写成了ss导致提交了两次都不是满分。
se=p[i].ends;
e=i;
}
}
cout<<p[s].id<<" "<<p[e].id;
return ;
}

//这道题能不能再简单易一点?就是利用string 来比较。给出了id 起始时间 终止时间。找出最早开始时间和最晚结束时间。那么因为时间格式都一样,不就直接比较就可以了?直接得出设置最先开始的,谁是最后结束的,输出id即可。

PAT Sign In and Sign Out[非常简单]的更多相关文章

  1. 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 ...

  2. 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 ...

  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. 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 ...

  5. 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 ...

  6. PAT1006:Sign In and Sign Out

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

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. WP8.1学习系列(第一章)——添加应用栏

    做过android开发的同学们应该都知道有个ActionBar的头部操作栏,而wp也有类似的一个固定在app页面里通常拥有的内部属性,就是应用栏.以前叫做ApplicationBar,现在wp和win ...

  2. 剑指offer——35复杂链表的复制

    这题很是巧妙. 突破了常规思维. 竟然可以把传入进来的链表和复制的链表链在一起.然后再算出slibling指针.最后在分离. 直接把空间复杂度变为O(1)了. 很巧妙,很实用. 题目: 请实现函数Co ...

  3. java(2) 面向对象

    1.类的封装 *在定义一个类时,将类中的属性私有化,即使用prviate关键字来修饰,私有属性只能在它所在的类中被访问.为了能让外界访问私有属性,需要提供一些使用public修饰的公有方法,其中包括用 ...

  4. sencha touch routes(路由) 传递中文参数

    使用路由的时候可以传递参数 如下: index.html#eaterylist/335/61/61/61/B/商户名称 其中6个参数依次是:商户编号/公众账号/微信号/校验号/服务类型/商户名称 因为 ...

  5. win10 与linux mint双系统 只能进入mint而无法进入windows的解决方案

    新购买了一块ssd,和以前的hdd硬盘一起装双系统:win10和mint ssd:win10       sdb1  sdb2 sdb3    sda2 hdd:  mint         sda1 ...

  6. wireshark和RawCap跟踪并解决中文乱码问题

    一.问题概述 说下程序的架构. 有个后台管理系统A,在页面修改数据后,会用httpClient发http请求给系统B: 系统B做了异步机制,收到A发的请求后,将数据封装为Mq消息发给RabbitMq, ...

  7. HDU 1455 Sticks(经典剪枝)

    Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  8. python的类中为什么要引入self

    从第一次接触python的面向对象编程时起就很看不惯它的self,简直反人类. 相关资源: What is the purpose of self in Python? http://stackove ...

  9. iOS8新特性(1)——UIAlertController

    一.iOS8介绍 iOS8 新特性,主要是UI上进行了统一 1.UIAlertController 2.UIPresentaionController:管理所有通过modal出来的控制器(看笔记) 3 ...

  10. 转基于概率的矩阵分解原理详解(PMF)

    上一篇博客讲到了推荐系统中常用的矩阵分解方法,RegularizedMF是对BasicMF的优化,而PMF是在RegularizedMF的基础上,引入概率模型进一步优化.假设用户U和项目V的特征矩阵均 ...