-
Title Description:
-
every day the first person to the computer room to open the door, the last one to leave the door closed. There are a lot of cluttered computer room check-in, sign-off records, please according to the records to find the day open and close the door.
-
Input:
-
The first line of the test input gives the total number of days of records N (n> 0), and the records for n days are listed below.
Each day the record in the first row gives the number of entries for the record m (M > 0), the following is the M row, each line is formatted as
Passport number check-in time sign-off time
The time is given by "hours: minutes: Seconds" (2 bits each), and the ID number is a string of no more than 15 length.
-
Output:
-
For each day of the record output 1 lines, that day open and close the person's identification number, the middle of 1 spaces separated.
Note: In the referee's standard test input, all records are guaranteed to be complete, and each person's check-in time is before the time of checkout, and there are not many people who sign in or sign out at once.
-
Sample input:
-
31me3021112225321 00:00:00 23:59:592ee301218 08:05:35 20:56:35ma301134 12:35:45 21:40:423cs301111 15:30:28 17:00:10sc3021234 08:00:00 11:25:25cs301133 21:45:00 21:58:40
-
Sample output:
-
ME3021112225321 me3021112225321ee301218 ma301134sc3021234 CS301133
-
-
Classic thought:
-
-
String size comparison directly to the time string, no other sort, such as cardinal sort
-
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace Std;
struct Check
{
Char no[20];
Char Arrive[8];
Char Leave[8];
}* A;
void Isort (int* max,int* min,int N)
{
*max = 0;
*min = 0;
for (int i=1;i<n;i++)
if (strcmp (a[i].arrive,a[*min].arrive) <0)
*min = i;
for (int i=1;i<n;i++)
if (strcmp (a[i].leave,a[*max].leave) >0)
*max = i;
return;
}
int main ()
{
int n,m;
cin>>n;
while (n--)
{
cin>>m;
A = (check*) malloc (sizeof (Check) *m);
int i = 0;
while (I<M)
{
cin>>a[i].no;
cin>>a[i].arrive;
cin>>a[i].leave;
i++;
}
int max,min;
Isort (&MAX,&MIN,M);
cout<<a[min].no<< "" <<a[max].no<<endl;
}
return 0;
}
Door opener and closing man