At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’s, you are supposed to find the ones who have unlocked and locked the door on that day.

Input Specification:

Each input file contains one test case. Each case contains the records for one day. The case starts with a positive integer M, which is the total number of records, followed by M lines, each in the format:

ID_number Sign_in_time Sign_out_time

where times are given in the format HH:MM:SS, and ID number is a string with no more than 15 characters.

Output Specification:

For each test case, output in one line the ID numbers of the persons who have unlocked and locked the door on that day. The two ID numbers must be separated by one space.

Note: It is guaranteed that the records are consistent. That is, the sign in time must be earlier than the sign out time for each person, and there are no two persons sign in or out at the same moment.

Sample Input:

3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40

Sample Output:

SC3021234 CS301133
翻译:
每天的开始,第一个登陆电脑的人会把门锁开,最后一个登出的人会把门关上,你有所有的登记的记录,现在你需要分别找到那个第一个解锁和最后一个锁门的人
输入:
每一个输入文件包含一个测试范例,每一个范例包含一天内的所有的记录,记录的开始是一个整数M,代表了这一天内总共的记录,随后共有M行记录,每一行的格式:
ID_number Sign_in_time Sign_out_time
时间以HH:MM:SS格式给出,ID号是不超过15个字符的字符串。
输出:
在一行内输出锁开门的人ID和把门锁住的人ID,用空格分开。
注意:保证记录一致。也就是说,签到时间必须早于每个人的退出时间,同时没有两个人登录或注销。

思路:
eindex保存为最早的登陆时间的人的下标,保存为oindex为最迟的登出的人的下标。
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int count;
	string buffer;
	string etime="9";
	string otime="0";
	int eindex= 0;
	int oindex= 0;
	vector names;
	vector loginTime;
	vector unloginTime;
	cin >> count;
	for (int i = 0; i < count; ++i) { cin >> buffer;
		names.push_back(buffer);
		cin >> buffer;
		loginTime.push_back(buffer);
		cin >> buffer;
		unloginTime.push_back(buffer);
	}
	for (int i = 0; i < count;++i)
	{
		if (loginTime[i] < etime) 
		{ 
			etime = loginTime[i]; 
			eindex = i; 
		} 
		if (unloginTime[i]> otime)
		{
			otime = unloginTime[i];
			oindex = i;
		}
	}
	cout << names[eindex] << " " << names[oindex];
	return 0;
}