HDU 1234 开门人和关门人

/*

今天发现自己是基地做题几乎最少的人

水几道题吧;

*/


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>

using namespace std;
int main(int argc, char *argv[])
{
	int n,m,hh1,hh2,mm1,mm2,ss1,ss2;
	int eh,es,em,lh,ls,lm;

	string on,off,stu;
	char c;
	cin>>n;
	while(n--)
	{	
		lh = lm = ls = 0;
		eh = 23;
		em = es = 59;
		cin>>m;
		//cin.get();
		while(m--)
		{
			cin>>stu>>hh1>>c>>mm1>>c>>ss1>>hh2>>c>>mm2>>c>>ss2;
			if(hh1<eh)
			{
				on = stu;
				eh = hh1,em = mm1,es = ss1;
			}
			else
			if(hh1==eh)
			{
				if(mm1<em)
				{
					on = stu;
					eh = hh1,em = mm1,es = ss1;
				}	
				else
				if(mm1==em && ss1<es)
				{
					on = stu;
					eh = hh1,em = mm1,es = ss1;
				}	
			}
			
			if(hh2>lh)
			{
				off = stu;
				lh = hh2,lm = mm2,ls = ss2;
			}
			else
			if(hh2==lh)
			{
				if(mm2>lm)
				{
					off = stu;
					lh = hh2,lm = mm2,ls = ss2;
				}	
				else
				if(mm2==lm && ss2>ls)
				{
					off = stu;
					lh = hh2,lm = mm2,ls = ss2;
				}	
			}
			
			
		} 
		cout<<on<<" "<<off<<endl;
	}
	return 0;
}


你可能感兴趣的:(HDU 1234 开门人和关门人)