Description
Every day, the first person to come to the computer room should open the door & # xff0c; the last person to leave should close the door. There are a bunch of messy computer room sign-in and sign-out records,Please find out who opened and closed the door on the day according to the records.
Enter
The first line of the test input gives the total number of days N of the record ( 0
The record of each day gives the number of recorded entries in the first line M ( 0
Certificate number Sign-in time Sign-out time
The time is given in “hour: minute: second” (each takes 2 digits) ,The document number is A character string whose length does not exceed 15.
Output
For each day’s record, output 1 line , that is, the ID number of the person who opened and closed the door on that day, in the middle 1 space separated.
Note :In the referee’s standard test input ,All records are guaranteed to be complete ,Everyone’s check-in time is before the check-out time,and There is no situation where multiple people sign in or sign out at the same time.
Sample input 1
1
3
CS2322231 11:30: 18 19:00:13
SC2421324 07:00:00 15:35:55
CS2401139 22:45:00 22:58:40
like Example output 1
SC2421324 CS2401139#include //Don’t mess with variables anymore
#include
int main()
{
int day;
scanf(“%d”,&day);
while (day–)
{
int num,i,tem[4]={1<<30,1<<30,1<<30,0};
struct {
char name[30];
int in[3];
int out[3];
} people[1000];
scanf(“%d”,&num);
for (i=0;i
{
int j;
scanf(“%s”,people[i].name);
for (j=0;j<3;j++)
{
scanf(“%d”,&people[i].in[j]);
getchar();
}
for (j=0;j<3;j++)
{
scanf(“%d “,&people[i].out[j]);
getchar();
}
}
for (i& #61;0;i
{
if (people[i].in[0]
{
tem[0 ]=people[i].in[0];
tem[1]=people[i].in[1];
tem[2 ]=people[i].in[2];
tem[3]=i;
}
else if ( people[i].in[0]==tem[0]&&people[i].in[1]
{
tem[0]& #61;people[i].in[0];
tem[1]=people[i].in[1];
tem[2]& #61;people[i].in[2];
tem[3]=i;
}
else if (people[ i].in[0]==tem[0]&&people[i].in[1]==tem[1]&&people[i].in[2]
{
tem[0]=people[i].in[0];
tem[1]=people[i ].in[1];
tem[2]=people[i].in[2];
tem[3]=i;
}
}
printf(“%s “,people[tem[3]].name);
memset(tem ,0,sizeof(int)*4);
for (i=0;i
{
if (people[i].out [0]>tem[0])
{
tem[0]=people[i].out[0];
tem [1]=people[i].out[1];
tem[2]=people[i].out[2];
tem [3]=i;
}
else if (people[i].out[0]==tem[0]&&people[ i].out[1]>tem[1])
{
tem[0]=people[i].out[0];
tem[1]=people[i].out[1];
tem[2]=people[i].out[2];
tem[3]=i;
}
else if (people[i].out[0]==tem[ 0]&&people[i].out[1]==tem[1]&&people[i].out[2]>tem[2])
{
tem[0]=people[i].out[0];
tem[1]=people[i].out[1];
tem[2]=people[i].out[2];
tem[3]=i;
}
}
printf(“%s\n”,people[tem[3]].name);
}
return 0;
}