zoukankan      html  css  js  c++  java
  • A1006. 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 // hahaha.cpp : 定义控制台应用程序的入口点。
     2 //
     3 
     4 #include <stdafx.h>
     5 #include <stdio.h>
     6 #include <iostream>
     7 #include <vector>
     8 #include <map>
     9 #include <string>
    10 #include <cstdio>
    11 #include <set>
    12 #include <algorithm>
    13 #include <string.h>
    14 using namespace std;
    15 const int maxn=1010;
    16 map<string,int> mp;
    17 struct per{
    18     int intime;
    19     int outtime;
    20     string name;
    21 }person[maxn];
    22 int nump=0;
    23 int getid(string a)
    24     {
    25     if(mp.find(a)!=mp.end())
    26         {
    27         return mp[a];
    28         }else
    29         {
    30         mp[a]=nump++;
    31         return mp[a];
    32         }
    33 
    34     }
    35 int time1(int h,int m,int s)
    36     {
    37     return h*3600+m*60+s;
    38     }
    39 
    40 
    41 
    42 
    43 int main()
    44 {
    45     int m1;
    46     scanf("%d",&m1);
    47     string name;
    48     int h,m,s;
    49     for(int i=0;i<m1;i++)
    50         {
    51 
    52         cin>>name;
    53         int id=getid(name);
    54         scanf("%d:%d:%d",&h,&m,&s);
    55         int in=time1(h,m,s);
    56 
    57         scanf("%d:%d:%d",&h,&m,&s);
    58         int out=time1(h,m,s);
    59         person[id].intime=in;
    60         person[id].outtime=out;
    61         person[id].name=name;
    62         }
    63 
    64     //输入完毕
    65     int min=86400,max=0;
    66     int idmin=0, idmax=0;
    67     for(int i=0;i<nump;i++)
    68         {
    69         if(person[i].intime<min)
    70             {
    71             idmin=i;
    72             min=person[i].intime;
    73             }
    74         if(person[i].outtime>max)
    75             {
    76             idmax=i;
    77             max=person[i].outtime;
    78             }
    79         }
    80 
    81     cout<<person[idmin].name<<" "<<person[idmax].name<<endl;
    82     return 0;
    83 }
  • 相关阅读:
    软件定义网络基础---REST API的设计规范
    软件定义网络基础---REST API概述
    软件定义网络基础---北向接口协议概述
    软件定义网络基础---SDN控制平面
    软件定义网络基础---NETCONF协议
    判断是否是完全二叉树
    G: 又见模法师
    欧拉定理+欧拉筛选法
    hdu-2036求任意多边形面积
    hdu1754 区间更新查询(单点更新+查询求区间最大值)
  • 原文地址:https://www.cnblogs.com/ligen/p/4341945.html
Copyright © 2011-2022 走看看