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. Colorful(Folders星语多彩文件夹) v1.7绿色版

    软件名称:星语多彩文件夹ColorfulFolders v1.7绿色版软件类别:国产软件运行环境:WinXP/2003/Vista/Win7/Win2008软件语言:简体中文授权方式:免费版软件大小: ...

  2. sqlserver 按日、周、月统计方法

    摘自于网络网络:http://blog.csdn.net/wanmdb/article/details/8080636 create table T(日期时间 datetime, 数量 int) in ...

  3. iOS 打包上传AppStore相关(1)-相关证书配置

    最近一个老项目需要更新迭代,一个新的项目需要上线.有一些自己出现的BUG,也有一些没搞懂到处翻资料的问题.在此想做一个总结,写一下总体步骤,尽可能的详细一些,以及自己的一些理解.有很多步骤因为我们查阅 ...

  4. redis事务、管道及消息通知探究

    一.事务 redis中使用事务,multi表示事务开始,对redis进行一些列操作之后再用exec提交事务,对应的方法分别是Transaction jedis.multi(),List<Obje ...

  5. bootstrap ch2清除浮动

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...

  6. mysql基本操作 [http://www.cnblogs.com/ggjucheng/archive/2012/11/03/2752082.html]

    创建表 简单的方式 CREATE TABLE person ( number INT(11), name VARCHAR(255), birthday DATE ); 或者是 CREATE TABLE ...

  7. js去除字符串中所有html标签及&nbsp符号

    近日在做项目的时候,经常会在页面上处理一些数据.结果发现自己js掌握的并不是很好.那就在这里记录js的点点滴滴吧. 1. 去除字符串中的 html 标签 function delHtmlTag(str ...

  8. 《剑指Offer》算法题——替换空格

    题目:请实现一个函数,将一个字符串中的空格替换成“ % 20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are % 20Happy. class Solution ...

  9. Chapter 2 Open Book——11

    "Hey, Dad, welcome home." hey爸爸,欢迎回家. "Thanks." He hung up his gun belt and step ...

  10. js 放大镜用法bug解决

    <img id="zoom_02" src='img/zhang5.jpg' data-zoom-image="img/zhang5p.jpg" /> ...