1006. Sign In and Sign Out (25)

时间限制
400 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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 "algorithm"
#include "string"
#include "vector"
using namespace std;

struct Sign
{
string Id;
string Start;
string End;
};

bool mycompare(Sign a, Sign b)
{
return a.Start < b.Start;
}
bool mycompare1(Sign a, Sign b)
{
return a.End > b.End;
}
int main()
{
int n;
cin >> n;
string finastart, finaend;
string id;string start;string end;
vector <Sign> vect;
Sign sign;
for(int i=0;i<n;i++)
{
cin >> id;
cin >> start;
cin >> end;
sign.Id = id;
sign.Start = start;
sign.End = end;
vect.push_back(sign);
}
sort(vect.begin(),vect.end(),mycompare);
finastart = vect[0].Id;
sort(vect.begin(),vect.end(),mycompare1);
finaend = vect[0].Id;
cout << finastart << " " << finaend << endl;
return 0;
}

浙江大学 pat 1006题解的更多相关文章

  1. 浙江大学Pat 1036 题解

    1036. Boys vs Girls (25) This time you are asked to tell the difference between the lowest grade of ...

  2. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  3. 浙江大学 pat 题解---58

    1058. A+B in Hogwarts (20) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue If you ...

  4. PAT 1001-1010 题解

    早期部分代码用 Java 实现.由于 PAT 虽然支持各种语言,但只有 C/C++标程来限定时间,许多题目用 Java 读入数据就已经超时,后来转投 C/C++.浏览全部代码:请戳 本文谨代表个人思路 ...

  5. pat甲级题解(更新到1013)

    1001. A+B Format (20) 注意负数,没别的了. 用scanf来补 前导0 和 前导的空格 很方便. #include <iostream> #include <cs ...

  6. PAT 1006

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

  7. 浙江大学PAT上机题解析之5-05. QQ帐户的申请与登陆

    实现QQ新帐户申请和老帐户登陆的简化版功能.最大挑战是:据说现在的QQ号码已经有10位数了. 输入格式说明: 输入首先给出一个正整数N(<=105),随后给出N行指令.每行指令的格式为:“命令符 ...

  8. 浙江大学PAT考试1069~1072(2013-11-2)

    11 题目地址:http://pat.zju.edu.cn/contests/pat-a-practise 1069: 由下降序和上升序两个四位数不断相减,然后得到新数据,始终会到达一个数字终止. 递 ...

  9. 浙江大学PAT考试1009~1012(1010上帝是冠军。。)

    哎,pat1010即使java书面,只有java书面,还增加了两个点,,.啊,智商捉佳,主要pat有些不给明确的范围.造成遐想空间.. 还是按顺序介绍.. 题目地址:http://pat.zju.ed ...

随机推荐

  1. HDU-------An Easy Task

    An Easy Task Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  2. Shell终端收听音乐--网易云音乐命令行版

    Musicbox:网易云音乐命令行版本 高品质网易云音乐命令行版本,简洁优雅,丝般顺滑,基于Python编写. 这款命令行的客户端使用 Python 构建,以 mpg123 作为播放后端: Vim 式 ...

  3. bootstrap IE8 相互兼容

    针对 IE8 仍然需要额外引入 Respond.js 文件(由于仍然利用了浏览器对媒体查询(media query)的支持,因此还需要做处理) <html lang="zh-cn&qu ...

  4. shrio登录验证

    shiro的认证过程也就是判断用户名和密码的过程,在认证过程中,用户需要提交实体信息(用户名)(Principals)和凭据信息(密码)(Credentials)来判断用户是否合法,最常见的" ...

  5. android移动开发学习笔记(二)神奇的Web API

    本次分两个大方向去讲解Web Api,1.如何实现Web Api?2.如何Android端如何调用Web Api?对于Web Api是什么?有什么优缺点?为什么用WebApi而不用Webservice ...

  6. 无法定位程序输入点__gxx_personality_v0的一个解决方法

    windows系统,使用mingw32-g++编译一个简单的工程,编译链接过程都没有错误提示,但是运行的时候会弹出提示框提示"无法定位程序输入点__gxx_personality_v0&qu ...

  7. Oracle新建实例后,修改sys和system密码。

    sqlplus/nolog connect sys as sysdba alert user sys identified by pwd;

  8. 。net定时关闭excel进程

    public void Application_Start() { // 在应用程序启动时运行的代码 System.Timers.Timer timer = new System.Timers.Tim ...

  9. centos 安装 ntpdate 并同步时间

    1.安装ntp yum install -y ntp 2.与一个已知的时间服务器同步 # time.nist.gov 是一个时间服务器 ntpdate time.nist.gov 3.删除本地时间并设 ...

  10. 更新BLUZ

    bluez的编译安装依赖好些软件,下面记录下,可能比较简陋. configure: error: GLib >= 2.28 is required解决方法:一般glib会被安装,主要是一些开发文 ...