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. C# 循环语句

    本次主要学习了for循环语句. for循环语句的基本格式是: for(初始条件;循环条件;状态改变) { 循环体; } break——中断循环,跳出循环. continue——停止本次循环,进入下次循 ...

  2. unity 退到桌面的 OnApplicationPause

    void OnApplicationFocus( bool isFocus ) { // Debug.Log("--------OnApplicationPause---" + i ...

  3. SQL Server服务开闭

    SQL Server(MSSQLSERVER)是必须要开启的,这个是数据库引擎服务,就像汽车的发动机一样. SQL Server代理(MSSQLSERVER)是代理服务,比如你有一些自动运行的,定时作 ...

  4. 安装appuim

    一.作为一名软件测试人员,对工作习惯和品质的有要求,要有对问题的敏感度,遇到问题就不能轻易放过,提前保存一切可能对分析解决问题有帮助的资料,不怕麻烦,尽可能的全面详细,不漏重点.若神经大条,嫌麻烦,不 ...

  5. Repeater控件的嵌套使用

    1.前台代码: <asp:Repeater ID="OrderList" runat="server" onitemdatabound="Ord ...

  6. do-while循环判断成绩的有效输入

    #include "stdio.h" void main() { int score; do { printf("请输入你的成绩(0-100):"); scan ...

  7. 十、oracle 常用函数

    一.字符函数字符函数是oracle中最常用的函数,我们来看看有哪些字符函数:lower(char):将字符串转化为小写的格式.upper(char):将字符串转化为大写的格式.length(char) ...

  8. mysql 发生系统错误1067的解决方法

    解决方法如下: 1.先删除mysql服务 控制面板->管理工具->服务,先停止mysql服务 开始->运行->输入cmd->sc delete mysql 服务删除 2. ...

  9. mybatis 总结(1)

    注意事项 1.在使用type 和JavaType 以及reusltType ,ofType的时候一定要设置"别名"在mybatis.cfg.xml中设置 <typeAlias ...

  10. $.getjson方法配合在url上传递jsoncallback=?参数,实现跨域获取指定网站某商品访问量

    across.php文件在域名www.cms.com程序中 <html><body><div id="pv">99</div>< ...