HDU-1234-opening and closing

Source: Internet
Author: User
Opens and closes

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 8825 Accepted Submission (s): 4577

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

The signing time of the document number is indicated by the 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

 

Code:

 

# Include "stdio. h "# include" string. h "typedef struct record {char number [16]; char come [9], leave [9];} record; int main () {int day, item, I; record s [100]; record temp; scanf ("% d", & day); while (day --) {scanf ("% d", & item ); for (I = 1; I <= item; I ++) scanf ("% s", & s [I]. number, & s [I]. come, & s [I]. leave); temp = s [1]; for (I = 1; I <= item; I ++) {if (strcmp (temp. come, s [I]. come)> 0) // select the earliest Value of "come" to temp = s [I];} printf ("% s", temp. number); temp = s [1]; for (I = 1; I <= item; I ++) {if (strcmp (s [I]. leave, temp. leave)> 0) // select the last leave time to assign to temp = s [I];} printf ("% s", temp. number); printf ("\ n");} return 0 ;}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.