基本思想:
无;
关键点:
无;
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<vector>
using namespace std;
bool flag;
struct node{
string id;
int sh;
int sm;
int ss;
int eh;
int em;
int es;
};
vector<node>vec;
bool cmp(node a, node b) {
if (flag) {
//找早到的;
if (a.sh != b.sh) {
return a.sh < b.sh;
}
else if (a.sm != b.sm) {
return a.sm < b.sm;
}
else {
return a.ss < b.ss;
}
}
else {
if (a.eh != b.eh) {
return a.eh > b.eh;
}
else if (a.em != b.em) {
return a.em > b.em;
}
else {
return a.es < b.es;
}
}
}
void init() {
vec.resize(0);
flag = true;
}
int main() {
int n;
while (cin >> n) {
flag = true;
for (int i = 0; i < n; i++) {
node no;
cin >> no.id;
scanf("%d:%d:%d %d:%d:%d", &no.sh, &no.sm, &no.ss, &no.eh, &no.em, &no.es);
vec.push_back(no);
}
sort(vec.begin(), vec.end(), cmp);
cout << vec[0].id;
flag = false;
sort(vec.begin(), vec.end(), cmp);
cout << " " << vec[0].id << endl;;
}
}
原文:https://www.cnblogs.com/songlinxuan/p/12490239.html