9-degree OJ 1013, 9-degree oj1013
Question 1013: Opening and Closing
Time Limit: 1 second
Memory limit: 32 MB
Special question: No
Submit: 4352
Solution: 2202
-
Description:
-
The first person to arrive at the data center should open the door every day, and the last person to leave should close the door. There are a bunch of messy data center sign-in and sign-out records. Please find out who opened and closed the door on the same day according to the records.
-
Input:
-
The first line of the test input shows the total number of days of the record N (N> 0). The N-day records are listed below.
The number of records per day M (M> 0) is given in the first row, and below is M rows. 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:
-
Output one line for each day's record, that is, the ID number of the person who opens the door and closes the door on the day, separated by a space in the middle.
Note: In the standard test input of the referee, all records must be complete. The signing time of each person is before the signing time, and no one else 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
# Include <stdio. h> # include <string. h> # include <stdlib. h> int N; typedef struct node {char name [20]; int start; int end;} node; node a [87000]; int comp1 (const void *, const void * B) {return (node *) a)-> start-(node *) B)-> start; // sort from small to large} int comp2 (const void * a, const void * B) {return (node *) a)-> end-(node *) B) -> end;} int main (int argc, char * argv []) {freopen ("1013.in"," r ", stdin); scanf (" % d ", & N); char s [20]; char e [20]; int I; int sh, sm, ss; int eh, em, es; while (N --) {int num; memset (a, 0, sizeof (a); scanf ("% d", & num); for (I = 0; I <num; ++ I) {scanf ("% s", a [I]. name); scanf ("% d: % d", & sh, & sm, & ss, & eh, & em, & es); a [I]. start = sh * 3600 + sm * 60 + ss; a [I]. end = eh * 3600 + em * 60 + es;} qsort (a, num, sizeof (node), comp1); strcpy (s, a [0]. name); qsort (a, num, sizeof (node), comp2); strcpy (e, a [num-1]. name); printf ("% s \ n", s, e) ;}return 0 ;}
By the way, I also contacted qsort usage. Remember int compare (const void * a, const void * B)