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:

测试用例由一个正整数M开始,表示记录的数量,接下来有M行,每一行的格式如下

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.

给出的时间格式是HH:MM: SS,ID不会超过15个字符

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.

对于每个测试用例,输出一行,解锁和锁的人的ID

The two ID numbers must be separated by one space.

两个ID必须用一个空格分开

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

自己的代码太low了,我去,我干啥要一个个读取,干嘛要一个个去比较,我是不是蠢货啊。

这里推荐直接字符串比较就可以了。我真的是,写了一大堆才发现自己有多蠢。。。这种错误不能犯第二次,下一次一定要记住。下面是网上的代码,真的很简练很爽。

#include<stdio.h>
#include<string.h>
int main(){
char lkman[],unlkman[];
char id[],in[],out[];
char fst[]={"24:00:00"},last[]={"00:00:00"};
int i,j,n;
scanf("%d",&n);
for(i=;i<n;i++){
scanf("%s %s %s",id,in,out);
if(strcmp(in,fst)<){
strcpy(fst,in);
strcpy(unlkman,id);
}
if(strcmp(out,last)>){
strcpy(last,out);
strcpy(lkman,id);
}
}
printf("%s %s\n",unlkman,lkman);
return ;
}

代码转载自:http://blog.csdn.net/sup_heaven/article/details/8451669

PAT1006的更多相关文章

  1. PAT1006:Sign In and Sign Out

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

  2. pat1006. Sign In and Sign Out (25)

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

  3. 一天两道PAT(2)1005,1006

    今天的pat1006没什么好说的.就记录一下1005的状况.先上题目. 卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重 ...

随机推荐

  1. 数据库 mysql 语句

    LAMP: Linux系统 A阿帕奇服务器 Mysql数据库 Php语言 mysql:常用代码 create table CeShi1( Uid varchar(50) primary key, Pw ...

  2. ural 1049. Brave Balloonists(标准分解式,数论)

    1049. Brave Balloonists Time limit: 2.0 secondMemory limit: 64 MB Ten mathematicians are flying on a ...

  3. wcf 配置总结

    最近在配置WCF的时候,需要一点麻烦,避免以后才出现错误,特记录起来 1.wcf需要使用用户名和X509证书验证 A.服务器的config配置 a.bindings/binding中使用 <se ...

  4. usbmanger android 底下USB的工作模式

    Android USB开发麻烦还是比较多的. 第一种:host模式 这种模式比较不错,由Android设备提供电源,然后与外部设备通信.举个例子来说:电脑连接USB设备,都是这个模式,非常常见的模式. ...

  5. Hadoop上的中文分词与词频统计实践 (有待学习 http://www.cnblogs.com/jiejue/archive/2012/12/16/2820788.html)

    解决问题的方案 Hadoop上的中文分词与词频统计实践 首先来推荐相关材料:http://xiaoxia.org/2011/12/18/map-reduce-program-of-rmm-word-c ...

  6. Volist标签

    Volist标签主要用于在模板中循环输出数据集或者多维数组. volist标签(循环输出数据) 闭合 非闭合标签 属性 name(必须):要输出的数据模板变量 id(必须):循环变量 offset(可 ...

  7. WebViewJavascriptBridge详细使用

    前言 WebViewJavascriptBridge是支持到iOS6之前的版本的,用于支持native的iOS与javascript交互.如果需要支持到iOS6之前的app,使用它是很不错的.本篇讲讲 ...

  8. Inno Setup入门(十六)——Inno Setup类参考(2)

    分类: Install Setup 2013-02-02 11:28 815人阅读 评论(0) 收藏 举报 这里将接着在前面的基础上介绍如何在自定义页面上添加按钮.按钮属于Tbutton类,该类继承自 ...

  9. mysql innobackupex备份工具

    先简单介绍一下这个工具:innobackupexinnobackupex比xtarbackup有更强的功能,它整合了xtrabackup和其他的一些功能,他不但可以全量备份/恢复,还可以基于时间的增量 ...

  10. linux下MMC/SD/SDIO驱动系列之二 ---- host注册过程(一)

    参考了 http://blog.csdn.net/xieweihua2012/article/details/12844733 在他的基础上更详细的解析源 ...................... ...