标签:des style blog http io color ar os sp
3 1 ME3021112225321 00:00:00 23:59:59 2 EE301218 08:05:35 20:56:35 MA301134 12:35:45 21:40:42 3 CS301111 15:30:28 17:00:10 SC3021234 08:00:00 11:25:25 CS301133 21:45:00 21:58:40
ME3021112225321 ME3021112225321 EE301218 MA301134 SC3021234 CS301133
水题,不解释了,就是简单的字符串应用。
AC代码:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
struct man
{
string id, st, et; //人的编号,签到时间,签退时间
};
man m[10005];
bool cmp1(man a, man b){
int x = (a.st[0]-'0')*10 + (a.st[1]-'0');
int xx = (a.st[3]-'0')*10 + (a.st[4]-'0');
int xxx = (a.st[6]-'0')*10 + (a.st[7]-'0');
int y = (b.st[0]-'0')*10 + (b.st[1]-'0');
int yy = (b.st[3]-'0')*10 + (b.st[4]-'0');
int yyy = (b.st[6]-'0')*10 + (b.st[7]-'0');
if(x==y && xx==yy) return xxx < yyy;
else if(x==y) return xx < yy;
return x < y;
}
bool cmp2(man a, man b){
int x = (a.et[0]-'0')*10 + (a.et[1]-'0');
int xx = (a.et[3]-'0')*10 + (a.et[4]-'0');
int xxx = (a.et[6]-'0')*10 + (a.et[7]-'0');
int y = (b.et[0]-'0')*10 + (b.et[1]-'0');
int yy = (b.et[3]-'0')*10 + (b.et[4]-'0');
int yyy = (b.et[6]-'0')*10 + (b.et[7]-'0');
if(x==y && xx==yy) return xxx > yyy;
else if(x==y) return xx > yy;
return x > y;
}
int main(){
// freopen("in.txt", "r", stdin);
int t, n;
scanf("%d", &t);
while(t--){
scanf("%d", &n);
for(int i=0; i<n; i++)
cin >> m[i].id >> m[i].st >> m[i].et;
sort(m, m+n, cmp1);
cout << m[0].id<<" ";
sort(m, m+n, cmp2);
cout << m[0].id << endl;
}
return 0;
}
HDU 1234 (浙大计算机研究生复试上机考试-2005年) 开门人和关门人 (水)
标签:des style blog http io color ar os sp
原文地址:http://blog.csdn.net/u013446688/article/details/41122559