Opens and closes
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 10622 accepted submission (s): 5419
Problem description the first person to arrive at the IDC every day should open the door, and the last person to leave should close the door. There are a bunch of messy data center signatures
Identify the person who opens or closes the door on the day according to the record.
The first line of input in the input test shows the total number of days of the record N (> 0 ). The records for N days are listed below.
The number of records per day m (> 0) is given in the first line. below is m, and the format of each row is
Credential number sign-in time sign-out time
The time is given by hour: minute: Second (two digits each). The document number is a string of no more than 15 characters.
Output outputs one line of records for each day, that is, the ID number of the person who opens the door and closes the door on the same day, separated by a space in the middle.
Note: In the standard test input of the referee, all records must be complete. The check-in time of each person must be before the signing time,
No one signs in or signs out at the same time.
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
After a week's delay, I finally dared to write it. Although I have referenced the code of other people, I have learned a little about the structure and it is still good.
#include<stdio.h>#include<string.h>struct stu{char number[30];char come[10];char go[10];}person,first,last;int main(){ int N,M,i; scanf("%d",&N); while(N--) { scanf("%d",&M); scanf("%s%s%s",person.number,person.come,person.go); first=person; last=person; while(--M) { scanf("%s%s%s",person.number,person.come,person.go); if(strcmp(person.come,first.come)<0) first=person; if(strcmp(person.go,last.go)>0) last=person; } printf("%s %s\n",first.number,last.number); } return 0;}