PAT Sign In and Sign Out[非常简单]
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[非常简单]的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- PAT1006:Sign In and Sign Out
1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- django进阶-查询(适合GET4以上人群阅读)
前言: 下篇博客写关于bootstrap... 一.如何在脚本测试django from django.db import models class Blog(models.Model): name ...
- Javascript 细节优化技巧(转)
break 语句和 continue 语句 break语句和continue语句都具有跳转作用,可以让代码不按既有的顺序执行. break语句用于跳出代码块或循环. var i = 0; while( ...
- HTML5 css3 阴影效果
阴影效果曾让 Web 设计师既爱又恨,现在,有了 CSS3,你不再需要 Photoshop,已经有网站在使用这个功能了,如 24 Ways website. -webkit-box-shadow: 1 ...
- 原生js--类、原型、构造函数
1.类和原型:原型对象是类的核心,类的所有实例都从同一个原型上继承属性和方法,原型对象是类的唯一标识 2.类和构造函数:构造函数通过new关键字来创建对象,构造函数的prototype属性被用作新对象 ...
- Git 多人协作开发的过程
Git可以完成两件事情: 1. 版本控制 2.多人协作开发 如今的项目,规模越来越大,功能越来越多,需要有一个团队进行开发. 如果有多个开发人员共同开发一个项目,如何进行协作的呢. Git提供了一个非 ...
- Sencha Cmd 5.0.1.231 是坑爹货
Sencha Cmd 5.0.1.231相比之前的版本有了很大的变动,存在很多坑爹之处,个人建议不要升级到这个版本,如果已经升级了的就卸载了还原到以前的版本吧. 历史版本下载地址:http://cdn ...
- 编译安装Ruby 1.9.3 安装CentOS
1. 准备需要的安装的东西 yum -y install make gcc openssl-devel zlib-devel gcc gcc-c++ make autoconf readline-de ...
- stopImmediatePropagation和stopPropagation (事件、防止侦听)
参考: ActionScript 3.0 Step By Step系列(六):学对象事件模型,从点击按扭开始 actionscript宝典 一.事件模型 egret中的事件模型和flash是一样的,但 ...
- JIRA - 使用指南(项目跟踪管理工具)
第一章.前言 JIRA 是澳大利亚 Atlassian 公司开发的一款优秀的问题跟踪管理软件工具,可以对各种类型的问题进行跟踪管理,包括缺陷.任务.需求.改进等.JIRA采用J2EE技术,能够跨 ...
- Windows Server 2008 R2之六活动目录域服务的卸载
活动目录域服务的卸载是将DC降级为独立服务器或成员服务器的过程. 在删除活动目录之前,为了防止操作失败操作系统故障,须对系统进行备份.同时,我们还必须对待删除的域控制器进行如下检查 1.是否有操作主控 ...