zoukankan      html  css  js  c++  java
  • 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
    
     1 #include <map>
     2 #include <set>
     3 #include <queue>
     4 #include <cmath>
     5 #include <stack>
     6 #include <vector>
     7 #include <string>
     8 #include <cstdio>
     9 #include <cstring>
    10 #include <climits>
    11 #include <iostream>
    12 #include <algorithm>
    13 #define wzf ((1 + sqrt(5.0)) / 2.0)
    14 #define INF 0x3f3f3f3f
    15 #define LL long long
    16 using namespace std;
    17 
    18 const int MAXN = 1005;
    19 
    20 struct Node
    21 {
    22     char s[MAXN];
    23     int h1, m1, s1, h2, m2, s2;
    24 }node[MAXN];
    25 int m;
    26 
    27 bool cmp1(Node a, Node b)
    28 {
    29     if (a.h1 != b.h1) return a.h1 < b.h1;
    30     if (a.m1 != b.m1) return a.m1 < b.m1;
    31     return a.s1 < b.s1;
    32 }
    33 
    34 bool cmp2(Node a, Node b)
    35 {
    36     if (a.h2 != b.h2) return a.h2 > b.h2;
    37     if (a.m2 != b.m2) return a.m2 > b.m2;
    38     return a.s2 > b.s2;
    39 }
    40 
    41 int main()
    42 {
    43     scanf("%d", &m);
    44     for (int i = 0; i < m; ++ i)
    45         scanf("%s %d:%d:%d %d:%d:%d", &node[i].s, &node[i].h1, &node[i].m1,
    46                &node[i].s1, &node[i].h2, &node[i].m2, &node[i].s2);
    47     sort(node, node + m, cmp1);
    48     cout <<node[0].s <<" ";
    49     sort(node, node + m, cmp2);
    50     cout <<node[0].s <<endl;
    51     return 0;
    52 }
  • 相关阅读:
    Charles截获iPhone网络请求
    android小Demo--圆球跟随手指轨迹移动
    《腾讯网UED体验设计之旅》读后感
    eatwhatApp开发实战(十四)
    [Unity2d系列教程] 006.Unity如何根据图片自动生成Animator
    [Unity2d系列教程] 005.Unity如何使用外部触控插件FingerGuesture
    eatwhatApp开发实战(十三)
    微服务平台技术架构
    Istio 流量劫持过程
    Istio 组件常用端口
  • 原文地址:https://www.cnblogs.com/GetcharZp/p/9576604.html
Copyright © 2011-2022 走看看