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. iNeuOS工业互联平台,开放设备驱动管理、服务驱动管理、云组态自定义画布等,促进平台开放、赋能和落地。发布:v2.3版本。

    目       录 1.      概述... 2 2.      iNeuOS平台演示... 2 3.      设备驱动管理... 2 4.      服务驱动管理... 3 5.      云组 ...

  2. PostgreSQL查询表以及字段的备注

    目录 查询所有表名称以及字段含义 查看所有表名 查看表名和备注 查看特定表名备注 查看特定表名字段 查询所有表名称以及字段含义 select c.relname 表名,cast(obj_descrip ...

  3. PyQt5UI文件转换为对应版本的py文件

    PyQt5 UI文件转换为对应版本的py文件 #coding=utf-8 ''' PyQt5 UI文件转换为对应版本的py文件 python -m PyQt5.uic.pyuic untitled.u ...

  4. 神器cut基因剪

    cut cut 不就是切嘛,没错就是它--我给他起了一个外号基因剪刀 来我们学一下怎么使用这个命令 cut --help [root@ESProbe ~]# cut --help Usage: cut ...

  5. 新文预览 | IoU-aware Single-stage Object Detector for Accurate Localization

    论文基于RetinaNet提出了IoU-aware sinage-stage目标检测算法,该算法在regression branch接入IoU predictor head并通过加权分类置信度和IoU ...

  6. F-NAScan:一款网络资产扫描工具

    此脚本的大概流程为: ICMP存活探测-->端口开放探测-->端口指纹服务识别-->提取快照(若为WEB)-->生成结果报表 用法 python NAScan.py -h 10 ...

  7. Python编写“求一元二次方程的解”

    #求一元二次方程的解 import math def equation(a,b,c): h=b*b-4*a*c #一元二次方程的解,百度来的 if h>=0: x1=(-b+math.sqrt( ...

  8. vue你真棒

    引子:什么是前后端分离和前后端不分离? 前后端分离指的是后端开发人员只负责用来书写后端逻辑代码,不用再去管前端页面的搭建,前端人员只负责做好前端页面效果,不用管数据,数据直接向后端人员要,后端和前端通 ...

  9. cmdb autoserver端表数据分析

    目录: 1.后台目录规划 autoserver: api: 接收数据并进行二次分析入库 API验证 backend : 负责后台管理 repository:负责管理模型类 (数据表) autoserv ...

  10. KMP 算法简单解释

    ​ 讲KMP算法,离不开BF,实际上,KMP就是BF升级版,主要流程和BF一样 ​ 不同是在匹配失败时能利用子串的特征减少回溯,利用根据子串特征生成的Next数组来减少 <( ̄︶ ̄)↗[GO!] ...