浙江大学 pat 1006题解
1006. Sign In and Sign Out (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 "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题解的更多相关文章
- 浙江大学Pat 1036 题解
1036. Boys vs Girls (25) This time you are asked to tell the difference between the lowest grade of ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- 浙江大学 pat 题解---58
1058. A+B in Hogwarts (20) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue If you ...
- PAT 1001-1010 题解
早期部分代码用 Java 实现.由于 PAT 虽然支持各种语言,但只有 C/C++标程来限定时间,许多题目用 Java 读入数据就已经超时,后来转投 C/C++.浏览全部代码:请戳 本文谨代表个人思路 ...
- pat甲级题解(更新到1013)
1001. A+B Format (20) 注意负数,没别的了. 用scanf来补 前导0 和 前导的空格 很方便. #include <iostream> #include <cs ...
- PAT 1006
1006. Sign In and Sign Out (25) At the beginning of every day, the first person who signs in the com ...
- 浙江大学PAT上机题解析之5-05. QQ帐户的申请与登陆
实现QQ新帐户申请和老帐户登陆的简化版功能.最大挑战是:据说现在的QQ号码已经有10位数了. 输入格式说明: 输入首先给出一个正整数N(<=105),随后给出N行指令.每行指令的格式为:“命令符 ...
- 浙江大学PAT考试1069~1072(2013-11-2)
11 题目地址:http://pat.zju.edu.cn/contests/pat-a-practise 1069: 由下降序和上升序两个四位数不断相减,然后得到新数据,始终会到达一个数字终止. 递 ...
- 浙江大学PAT考试1009~1012(1010上帝是冠军。。)
哎,pat1010即使java书面,只有java书面,还增加了两个点,,.啊,智商捉佳,主要pat有些不给明确的范围.造成遐想空间.. 还是按顺序介绍.. 题目地址:http://pat.zju.ed ...
随机推荐
- 微信小程序开发(1)
底限,HTML,CSS,JS得会 先过一下官方的文档:https://mp.weixin.qq.com/debug/wxadoc/introduction/index.html?t=20161230 ...
- 如何通过fpmmm和zabbix来监控客户机上MariaDB数据库运行情况
首先在客户机安装MariaDB和zabbix,参考上一篇 安装fpmmm的过程主要参考[1]. 安装fpmmm的依赖 shell> yum install php-cli php-process ...
- js导航栏样式变换
<script type="text/javascript"> $(function(){ var lis = $(".submenu").chil ...
- Gentoo/Arch常用软件配置
## Desktop Environment ### GNOME ### KDE ### LXDE ### Xfce ## Window Managers ### dwm x11-wm/dwm ### ...
- bootstrap IE8 相互兼容
针对 IE8 仍然需要额外引入 Respond.js 文件(由于仍然利用了浏览器对媒体查询(media query)的支持,因此还需要做处理) <html lang="zh-cn&qu ...
- asp.net——初识多线程
1.首先讲解一下什么是线程(该定义是参考线程的百度百科) 线程,有时被称为轻量级进程(Lightweight Process,LWP),是程序执行流的最小单元.一个标准的线程由线程ID,当前指令指针( ...
- Apache 关于 mod_rewrite 遇到 %2F或%5C (正反斜杠)等特殊符号导致URL重写失效出现404的问题
.htaccess 文件 <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d Rew ...
- hdu1034
#include<stdio.h>const int MAXN=1000;int a[MAXN];int main(){ int n; int i; while(scanf("% ...
- MocorDroid编译工程快速建立编译环境
function sprdLunch(){ declare -a arrProj arrProj=`find out/target/product -name previous_build ...
- SnackbarUtils:一行代码搞定Snackbar
此文章是我在简书的文章 http://www.jianshu.com/p/f4ba05d7bbda Snackbar在Android中的使用日益广泛,很大程度上替代了传统的Toast,相比Toast拥 ...