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 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
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
#define wzf ((1 + sqrt(5.0)) / 2.0)
#define INF 0x3f3f3f3f
#define LL long long
using namespace std; const int MAXN = ; struct Node
{
char s[MAXN];
int h1, m1, s1, h2, m2, s2;
}node[MAXN];
int m; bool cmp1(Node a, Node b)
{
if (a.h1 != b.h1) return a.h1 < b.h1;
if (a.m1 != b.m1) return a.m1 < b.m1;
return a.s1 < b.s1;
} bool cmp2(Node a, Node b)
{
if (a.h2 != b.h2) return a.h2 > b.h2;
if (a.m2 != b.m2) return a.m2 > b.m2;
return a.s2 > b.s2;
} int main()
{
scanf("%d", &m);
for (int i = ; i < m; ++ i)
scanf("%s %d:%d:%d %d:%d:%d", &node[i].s, &node[i].h1, &node[i].m1,
&node[i].s1, &node[i].h2, &node[i].m2, &node[i].s2);
sort(node, node + m, cmp1);
cout <<node[].s <<" ";
sort(node, node + m, cmp2);
cout <<node[].s <<endl;
return ;
}
pat 1006 Sign In and Sign Out(25 分)的更多相关文章
- PAT甲级:1036 Boys vs Girls (25分)
PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...
- PAT甲级:1089 Insert or Merge (25分)
PAT甲级:1089 Insert or Merge (25分) 题干 According to Wikipedia: Insertion sort iterates, consuming one i ...
- PAT 乙级 1080 MOOC期终成绩 (25 分)
1080 MOOC期终成绩 (25 分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习“数据结构”课程的学生,想要获得一张合格证书,必须首先获得不少于200分的 ...
- pat 1002 A+B for Polynomials (25 分)
1002 A+B for Polynomials (25 分) This time, you are supposed to find A+B where A and B are two polyno ...
- PAT 甲级 1145 Hashing - Average Search Time (25 分)(读不懂题,也没听说过平方探测法解决哈希冲突。。。感觉题目也有点问题)
1145 Hashing - Average Search Time (25 分) The task of this problem is simple: insert a sequence of ...
- PAT 甲级 1066 Root of AVL Tree (25 分)(快速掌握平衡二叉树的旋转,内含代码和注解)***
1066 Root of AVL Tree (25 分) An AVL tree is a self-balancing binary search tree. In an AVL tree, t ...
- PAT 甲级 1055 The World's Richest (25 分)(简单题,要用printf和scanf,否则超时,string 的输入输出要注意)
1055 The World's Richest (25 分) Forbes magazine publishes every year its list of billionaires base ...
- PAT 甲级 1047 Student List for Course (25 分)(cout超时,string scanf printf注意点,字符串哈希反哈希)
1047 Student List for Course (25 分) Zhejiang University has 40,000 students and provides 2,500 cou ...
- PAT 甲级 1039 Course List for Student (25 分)(字符串哈希,优先队列,没想到是哈希)*
1039 Course List for Student (25 分) Zhejiang University has 40000 students and provides 2500 cours ...
- shell练习--PAT试题1010:一元多项式求导 (25 分)(失败案例喜加一)
---恢复内容开始--- 1010 一元多项式求导 (25 分) 设计函数求一元多项式的导数.(注:xn(n为整数)的一阶导数为nxn−1.) 输入格式: 以指数递降方式输入多项式非零项系 ...
随机推荐
- [HDU5001]Walk
Problem Description I used to think I could be anything, but now I know that I couldn't do anything. ...
- Ceph Paxos相关代码解析
Leader选举 Ceph中的leader选举是一个Paxos Lease过程,与BasicPaxos的目的不同.后者用于解决数据一致性问题,而Paxos Lease是为了选举出一个leader承担m ...
- opencv::sift特征提取
SIFT特征检测介绍 SIFT(Scale-Invariant Feature Transform)特征检测关键特性: -建立尺度空间,寻找极值 -关键点定位(寻找关键点准确位置与删除弱边缘) -关键 ...
- gojs常用API (中文文档)
常用API 操作类API API 例子 应用场景 添加节点 myDiagram.model.addNodeData(node); var node = {}; node["key&q ...
- CSAPP: 位操作实现基本运算
目录 实验要求 实现代码 1.pow2plus1 2.pow2plus4 3.bitXor 4.tmin 5.isTmax 6.allOddBits 7.negate 8.isAsciiDigit 9 ...
- kubernetes kubelet组件中cgroup的层层"戒备"
cgroup是linux内核中用于实现资源使用限制和统计的模块,docker的风靡一时少不了cgroup等特性的支持.kubernetes作为容器编排引擎,除了借助docker进行容器进程的资源管理外 ...
- 面试必问的Synchronized知道这些就可以了
Synchronized关键字算是Java的元老级锁了,一开始它撑起了Java的同步任务,其用法简单粗暴容易上手.但是有些与它相关的知识点还是需要我们开发者去深入掌握的.比如,我们都知道通过Synch ...
- spring security原理-学习笔记2-核心组件
核心组件 AuthenticationManager,ProviderManager和AuthenticationProvider AuthenticationManager只是一个接口,实际中是如何 ...
- js图片随机切换
使用js做到随机切换图片 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...
- Windows 10 + kali Linux 双系统安装教程(详细版)
准备工具如下: kali Linux 镜像 准备一4G以上的U盘 制作U盘启动盘工具- Win32DiskImager 添加引导工具-EasyBCD 留出一个空的盘,哪个盘的空间比较大可以压缩出大概2 ...