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
题目分析:给定数据排序 ,直接利用vector对结构体排序 将比较函数重写就可以了
注意sort中比较函数 返回true是不交换的 鉴于现在我水平较低 之后会尝试分析 源码的(大概
 #include<iostream>
#include<string>
#include<stdlib.h>
#include<vector>
#include<algorithm>
using namespace std;
#define MaxNum 1
typedef struct Node {
string ID_numebr;
string Sign_in_time;
string Sign_out_time;
}S;
typedef struct Time {
int H;
int M;
int S;
}T;
T t1, t2;
int Atoi(string str, int i, int j)
{
int num = ;
while (i<j)
{
num = num * + str[i] - '';
i++;
}
return num;
}
bool comp2(const S& a, const S& b)
{ t1.H = Atoi(a.Sign_out_time, , );
t1.M = Atoi(a.Sign_out_time, , );
t1.S = Atoi(a.Sign_out_time, , );
t2.H = Atoi(b.Sign_out_time, , );
t2.M = Atoi(b.Sign_out_time, , );
t2.S = Atoi(b.Sign_out_time, , );
if (t1.H > t2.H)
return true;
else if (t1.H == t2.H && t1.M > t2.M)
return true;
else if (t1.M == t2.M && t1.S > t2.S)
return true;
else
return false;
} bool comp1(const S& a, const S& b)
{ t1.H = Atoi(a.Sign_in_time, , );
t1.M = Atoi(a.Sign_in_time, , );
t1.S = Atoi(a.Sign_in_time, , );
t2.H = Atoi(b.Sign_in_time, , );
t2.M = Atoi(b.Sign_in_time, , );
t2.S = Atoi(b.Sign_in_time, , );
if (t1.H < t2.H)
return true;
else if (t1.H == t2.H && t1.M < t2.M)
return true;
else if (t1.M == t2.M && t1.S < t2.S)
return true;
else
return false;
} int main()
{
vector<Node> N;
S s;
int n;
cin >> n;
for (int i = ; i < n; i++)
{
cin >> s.ID_numebr >> s.Sign_in_time >> s.Sign_out_time;
N.push_back(s);
}
sort(N.begin(), N.end(), comp1);
cout << N[].ID_numebr<<" ";
sort(N.begin(), N.end(), comp2);
cout << N[].ID_numebr;
return ;
}

1006 Sign In and Sign Out (25 分)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

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

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

  8. 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 ...

  9. 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 ...

  10. 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 th ...

随机推荐

  1. linux使用php动态安装模块mysqli.so(ext/mysqlnd/mysqlnd.h: 没有那个文件或目录)

    由于我先安装的php,再安装的mysql! 正常过程: 1.安装mysql 2.安装php configure时带–with-mysql参数 现在我不想重装,因此使用phpize动态安装mysqli, ...

  2. PHP变量存储结构

    首先声明,我并没有去读PHP的源码,只是对于PHP的有时候诡异的表现感兴趣,找了一下开发人员laruence的博客结合PHP提供的函数debug_zval_dump刺探得到了本博客所阐述的工作机理.如 ...

  3. .NET Conf: Xamarin专场会议3.23 开幕

    聚焦于 Xamarin 的 NET Conf 是一项免费的为期一天的直播活动,来自社区和.NET产品团队的演讲者正在使用Xamarin技术构建本机移动应用程序!Xamarin允许您使用C#(而不是Ja ...

  4. 【Python】2.19学习笔记 成员运算符,身份运算符,运算符优先级

    成员运算符 暂时不会用,等学链表时再补充 \(in\) 与 \(not in\) \(in\):如果在指定序列中找到指定值,则返回\(true\) \(not in\):如果在指定序列中找到指定值,则 ...

  5. 5分钟使用NetModular 完成通讯录 App 开发

    原版连接:https://www.cnblogs.com/shanyou/p/12520894.html NetModular(后文简称NM)是 OLDLI 堪称艺术品级的应用开发框架,它基于经典领域 ...

  6. Android NDK JNI 入门笔记-day04-NDK实现Hash算法

    * Android NDK JNI 入门笔记目录 * 开头 前面的学习,我们已经掌握了 NDK 开发的必备知识. 下一步就要多实践,通过创造问题并解决问题,来增加熟练度,提升经验. 日常开发中,经常会 ...

  7. Natas18 Writeup(Session登录,暴力破解)

    Natas18: 一个登录界面,查看源码,发现没有连接数据库,使用Session登录,且$maxid设定了不大的上限,选择采取爆破. 源码解析: <html> <head> & ...

  8. 写了个python脚本,循环执行某一个目录下的jmeter脚本————解决的问题,每次回归时,都得一个个拉取

    import os import time #需要你改的就这3个参数 #path是放你jmx脚本的文件夹路径 path="D:\\桌面\\每次都是从共享上考最新的\\" #jtl_ ...

  9. JSP+Servlet+JDBC+Mysql实现的天才会议管理系统

    本文存在视频版本,请知悉 项目简介 项目来源于:https://github.com/hegexunmeng/meeting-system 这次分享一个会议管理系统,前端后端几乎没有使用任何框架,适合 ...

  10. canvas.toDataURL()报错的解决方案全都在这了

    报错详尽信息 Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases ...