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 <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std; int n;
struct Node
{
//char s1[50];
//char s2[50];
//char s3[50];
string s1,s2,s3;
}a[];
int cmp1(Node x,Node y)
{
return x.s2<y.s2;
}
int cmp2(Node x,Node y)
{
return x.s3<y.s3;
}
int main()
{
while(cin>>n){
for(int i=;i<n;i++){
cin>>a[i].s1>>a[i].s2>>a[i].s3;
}
string str1,str2;
sort(a,a+n,cmp1);
str1=a[].s1;
sort(a,a+n,cmp2);
str2=a[n-].s1;
cout<<str1<<" "<<str2<<endl;
}
return ;
}

PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分) (排序)的更多相关文章

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

  2. PAT (Basic Level) Practice (中文)1070 结绳 (25 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1070 结绳 (25 分) 凌宸1642 题目描述 给定一段一段的绳子,你需要把它们串成一条绳.每次串连的时候,是把两段绳子对折,再如下 ...

  3. PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642 题目描述: "单身狗"是中文对于单身人士的一种爱称.本题请你从上万人的大 ...

  4. PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) 凌宸1642

    PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) 目录 PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) ...

  5. PAT (Advanced Level) Practice 1002 A+B for Polynomials 分数 25

    This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each ...

  6. PAT (Basic Level) Practice (中文)1030 完美数列 (25 分) (有点意思)

    给定一个正整数数列,和正整数 p,设这个数列中的最大值是 M,最小值是 m,如果 M≤mp,则称这个数列是完美数列. 现在给定参数 p 和一些正整数,请你从中选择尽可能多的数构成一个完美数列. 输入格 ...

  7. PAT (Basic Level) Practice (中文)1070 结绳 (25 分) (优先队列)

    给定一段一段的绳子,你需要把它们串成一条绳.每次串连的时候,是把两段绳子对折,再如下图所示套接在一起.这样得到的绳子又被当成是另一段绳子,可以再次对折去跟另一段绳子串连.每次串连后,原来两段绳子的长度 ...

  8. PAT (Basic Level) Practice (中文)1025 反转链表 (25分)

    1025 反转链表 (25分) 给定一个常数 K 以及一个单链表 L,请编写程序将 L 中每 K 个结点反转.例如:给定 L 为 1→2→3→4→5→6,K 为 3,则输出应该为 3→2→1→6→5→ ...

  9. PAT (Basic Level) Practice (中文)1054 求平均值 (20 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1054 求平均值 (20 分) 题目描述 本题的基本要求非常简单:给定 N 个实数,计算它们的平均值.但复杂的是有些输入数据可能是非法的 ...

随机推荐

  1. 网络安全初级实战笔记(一):owasp zap 暴力破解

    网络安全里装着好多人的侠客梦.但是不能触碰铁律,所以,只小小的自娱自乐. 自己练习,大都会用到DVWA,一个很好的安全测试平台,自己搭建(很简单,傻瓜式搭建),自己设置安全级别,自己验证各种漏洞攻击方 ...

  2. javascript get set读取器

    class Person{ constructor(name, id){ let _name = name, _id = id; Object.defineProperties(this, { nam ...

  3. istio-ServiceMesh解决方案

    istio-ServiceMesh解决方案 istio(1):ServiceMesh解决方案-k8s安装istio istio(2):流量管理-基于不同版本访问规则控制 istio(3):流量管理-基 ...

  4. debian 和ubuntu 安装ifconfig 命令

    # apt update # apt install net-tools

  5. 基于 H5 Canvas 实现楼宇新风系统

    前言 现如今,新型冠状病毒疫情牵动着每一个人的神经,每天起床后的第一件事就是打开疫情地图,看看最新的疫情数据. (http://www.hightopo.com/demo/coronavirus/) ...

  6. make: *** No targets specified and no makefile found. Stop.错误

    # make make: *** No targets specified and no makefile found. Stop. # yum install gcc gcc-c++ gcc-g77 ...

  7. 仅需60秒,使用k3s创建一个多节点K8S集群!

    作者: Dawid Ziolkowski丨Container Solution云原生工程师 最近,我一直在Kubernetes上进行各种测试和部署.因此,我不得不一次又一次创建和销毁Kubernete ...

  8. 进阶之路 | 奇妙的Window之旅

    前言 本文已经收录到我的Github个人博客,欢迎大佬们光临寒舍: 我的GIthub博客 学习清单: Window&WindowManagerService Window&Window ...

  9. HttpMessageNotReadableException

    HttpMessageNotReadableException 情况描述: spring boot web项目,尝试使用热部署工具. Controller只写了用来测试异常的方法, 异常处理器去捕获异 ...

  10. C语言:字符串拷贝(截取)、查找

    C语言:字符串拷贝(截取).查找 很惭愧,学了这么久别的语言,一直没有好好学C和C++,所以现在开始认真C/C++的一些特性和比较,这里记录下C语言拷贝和截取的一些方式,由于系统库带的函数不方便,所以 ...