浙江大学 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 ...
随机推荐
- sql 时间格式化
sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, 20) 结果:2007-0 ...
- CentOS+OpenCV图像的读入、显示
以管理员身份运行su root输入密码 定位到自己的桌面目录 gedit 1.cpp 编辑内容 #include<opencv2/opencv.hpp>using namespace cv ...
- CSS3 filter(滤镜) 属性
filter 属性定义了元素(通常是<img>)的可视效果 语法: object.style.WebkitFilter="grayscale(100%)" 小栗子: 修 ...
- 常用的 css 样式 记录
1.font-style 属性指定文本的字体样式. 对应的值有: normal 默认值.浏览器显示一个标准的字体样式; italic 浏览器会显示一个斜体的字体样式; oblique 浏览器会显 ...
- eclipse 一些快捷键
快捷键 alt + 上下方向键 向后缩进 shift + tab 整体向左移动 tab 就是向右移动 ctrl + Q 就是构建有参的构造方法 ctrl + E 是get set 方法,要把quick ...
- php取整
php取整的方法一共有4中,分别是ceil(),floor(),round(),intval(). 1.ceil--向上取整,即不小于当前的下一个整数,如果有小数则进一位. 返回的是float类型 & ...
- ASP.NET网站怎么发布 Web项目程序怎么发布部署(暂时收藏)
Web程序如何发布部署呢.网站项目做好了,需要发布出来,提交给客户,装上服务器.那怎么在ASP.NET开发环境中将网站程序发布出来呢 ^_^ 工具/原料 Visual Studio 2010 ( ...
- 总结:liunx常见命令集合
没有系统学习过liunx,把工作中遇到的liunx命令集合信息如下: 1.nc传送文件 之前总是用rsync, 今天遇到了一个从阿里云服务器传送文件到我们公司的内网服务器,这就不能传了,又想用一致的文 ...
- mmmmmmmm
// // AView.m // AutoLayout // // Created by ZhuYi on 16/5/24. // Copyright © 2016年 ZY. All rights r ...
- 【USACO】草地排水
Drainage Ditches 草地排水 usaco 4.2.1描述在农夫约翰的农场上,每逢下雨,Bessie最喜欢的三叶草地就积聚了一潭水.这意味着草地被水淹没了,并且小草要继续生长还要花相当长一 ...