题干:

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

题目大意:

每天早上,第一个在电脑室签名的人会打开门,最后一个在电脑室签名的人会锁上门。根据签到记录和签到记录,你应该找到当天开门和锁门的人。

解题报告:

直接模拟即可。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define FF first
#define SS second
#define ll long long
#define pb push_back
#define pm make_pair
using namespace std;
typedef pair<int,int> PII;
const int MAX = 2e5 + 5;
int n;
map<string,int> st,ed;
char s[MAX];
int h1,m1,s1,h2,m2,s2;
int main()
{cin>>n;for(int i = 1; i<=n; i++) {scanf("%s %d:%d:%d %d:%d:%d",s,&h1,&m1,&s1,&h2,&m2,&s2);st[s] = h1*3600 + m1*60+s1;ed[s] = h2*3600 + m2*60+s2;}string stname,edname;int stt=0x3f3f3f3f,edt;for(auto x : st) {if(x.SS < stt) {stt = x.SS;stname = x.FF;}}for(auto x : ed) {if(x.SS > edt) {edt = x.SS;edname = x.FF;}}cout << stname << " " << edname << endl;return 0 ;
}

【PAT - 甲级1006】Sign In and Sign Out (25分)(STLmap)相关推荐

  1. 【PAT甲级 BigInteger运算】1024 Palindromic Number (25 分) Java 全部AC

    题目 题解 Java 一开始用C++写的,有两个大数的测试点过不去,后来改用Java的BigInteger开挂,全部通过 import java.io.BufferedReader; import j ...

  2. 【PAT甲级 排序】1012 The Best Rank (25 分) C++ 全部AC

    题目 中规中矩的一道题.排名的顺序一开始没太明白,但是理解之后写起来挺流畅的,没什么坑. 解题思路:题目会给出所有学生所有科目的成绩.想要看分学生的学号. 我们要先给这些学生单科成绩排序,算出它们的单 ...

  3. 【PAT甲级 排序】1036 Boys vs Girls (25 分) C++

    题目 是个水题,排序就完事. 输出女生最高分的学生,男生最低分的学生,并计算分差. 一点点小坑:让输出啥,看清楚再写,不要靠记忆做题 一开始把题目中要求输出的NA看成了NAN,一开始有两个测试用例过不 ...

  4. PAT甲级 -- 1079 Total Sales of Supply Chain (25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  5. PAT甲级 -- 1090 Highest Price in Supply Chain (25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  6. PAT甲级 -- 1106 Lowest Price in Supply Chain (25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  7. PAT甲级1006 Sign In and Sign Out:[C++题解]字符串处理

    文章目录 题目分析 题目链接 题目分析 读入三个字符串. 需要记录最早开门的人的id和时间,最晚离开的人的id和时间. 本题的简单之处在于 时间的位数都相同,比如 10点和01点.因此这样的时间大小比 ...

  8. PAT甲级1151 LCA in a Binary Tree (30 分):[C++题解]LCA、最低公共祖先、哈希表映射

    文章目录 题目分析 题目链接 题目分析 来源:acwing 分析: 和下面这道题几乎是同一题:PAT甲级1143 Lowest Common Ancestor (30 分):[C++题解]LCA.最低 ...

  9. PAT甲级1087 All Roads Lead to Rome (30分):[C++题解]dijkstra求单源最短路综合、最短路条数、保存路径

    文章目录 题目分析 题目链接 题目分析 来源:acwing 分析: 首先这是一道dijkstra算法求最短路的题目,不过此题较为复杂.首先需要将字符串城市名映射成数字,这里使用hash table 名 ...

  10. PAT甲级1135 Is It A Red-Black Tree (30分):[C++题解]判断红黑树

    文章目录 题目分析 题目链接 题目分析 分析 给定前序遍历,同时红黑树一定是二叉搜索树,所以它的中序遍历就是从小到大排序.因此这道题是给定了前序遍历和中序遍历让建立二叉搜索树(BST). 数据结构中有 ...

最新文章

  1. 成功解决ValueError: Dimension 1 in both shapes must be equal, for ‘Assign_8‘ (op: ‘Assign‘) with input s
  2. GAN模型-分析角度
  3. Python 找出一个整数数组中,第二大的数。
  4. 兄弟机cnc系统面板图解_FANUC软操作面板的应用介绍,真的太详细了
  5. 【洛谷 P2513】 [HAOI2009]逆序对数列(DP)
  6. 开源项目:SandDance-数据可视化
  7. jQuery幸运大转盘_jQuery+PHP抽奖程序
  8. NLP︱句子级、词语级以及句子-词语之间相似性(相关名称:文档特征、词特征、词权重)
  9. ICLR2020 双盲审稿资质雪崩:47%审稿人在领域内没发过论文,8分论文你也能审!...
  10. 第三:启发式搜索:A* 算法
  11. java过滤器命名_java 过滤指定后缀文件
  12. 基于Packet Tracer的校园网设计与仿真 文档+答辩PPT+配置文件
  13. NLS_LANG详解
  14. 人工智能未来十大趋势,22年最新
  15. Shiro是如何进行权限管理
  16. 大象做梦传媒:做好企业年会策划活动执行方案
  17. JavaSE第21篇:Java之IO流下篇
  18. ant design Menu组件子菜单样式设置
  19. PingCAP Clinic 诊断服务简介
  20. 【190222】VC局域网视频监控系统服务器源代码

热门文章

  1. ADO.NET+Access: 3,参数 @departmentName 没有默认值
  2. phpMyAdmin导入大的sql文件
  3. BulkLoader类使用
  4. Web-DispatcherServletUrlPatterns
  5. Flex 学习站点汇总,(FLEX学习站点、博客、论坛)
  6. nutch2.1分布式抓取
  7. 【数据结构与算法】【算法思想】贪心算法
  8. [剑指offer][JAVA]面试题[51][数组中的逆序对][归并排序]
  9. mysql gzip_在mysql中存储GZIP:ed文本?
  10. python程序中想使用正则表达式_python中正则表达式的使用方法