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.) 输入格式: 以指数递降方式输入多项式非零项系 ...
随机推荐
- PHP current
1.函数的作用:返回数组的当前元素 2.函数的参数: @params array &$array 3.例子: <?php $arr = [null,'PK',false]; : ; ec ...
- 运用第一性原理探寻AI本质
摘要:使用第一性原理探讨理解AI本质. 文章来源:宜信技术学院|宜信支付结算团队技术分享第二期-支付结算机器学习技术团队负责人 刘创 分享<AI与第一性原理> 分享者:宜信支付结算机器学习 ...
- Cocos2d-x 学习笔记(11.3) JumpBy JumpTo
1. JumpBy JumpTo JumpBy,边跳边平移,不只做垂直向上的抛物动作,同时还在向终点平移.JumpTo是JumpBy的子类. 1.1 成员变量 create方法 JumpBy: Vec ...
- 详解立即执行函数(function(){}()),(function(){})()
要知道这几种写法之间的区别,我们要先聊些题外话——js中函数的两种命名方式,即表达式和声明式. 函数的声明式写法为:function foo(){/*...*/},这种写法会导致函数提升,所有func ...
- 存储过程导出数据到csv
USE [database] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- P_AutoInspect_LogToFilePath 'F ...
- 编程语言分类 + python解释器的安装 + jupyter的使用(day 02整理)
目录 一.昨日内容回顾 一 计算机基础之编程 (一) 什么是编程语言 (二) 什么是编程 (三) 为什么编程 二 计算机组成 (一) CPU (二) 存储器 (三) I/O设备 (四) 多核CPU ( ...
- InitializingBean,spring 初始化bean
springframework的提供接口,InitializingBean接口为bean提供了初始化方法的方式,它只包括afterPropertiesSet方法,凡是继承该接口的类,在初始化bean的 ...
- js 的隐式转换与显式转换
隐式转换 1.undefined与null相等,但不恒等(===) 2.一个是number一个是string时,会尝试将string转换为number 3.隐式转换将boolean转换为numbe ...
- 基于Mustache实现sql拼接
目录 一.前言 二.Mustache语法 三.Mustache拼接sql 一.前言 Mustache语法是一种模板语法,它可以帮我们拼接我们想要的东西.入职新公司,而项目里的sql语句就是用Musta ...
- 初学android小笔记(一)
一:应用外观基础设置 (1)去掉标题栏:打开Android Manifest文件,将theme如下设置 (2)改应用图标:将icon指定图片改为想要的app图标即可 (3)改应用名字: 在Manife ...