AcWing 4473. 老板的作息表
原题链接
中等
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
typedef long long ll;
using namespace std;
const int N = 5e4 + 10;
const int Mod = 998244353;
string str[N];
int main() {
int n;
cin >> n;
getchar();
for (int i = 0; i < n; i++)getline(cin, str[i]);
sort(str, str + n, [](auto a1, auto a2) {return a1 + a2 < a2 + a1; });
//直接字典序即可,不用拼接求最大的,所以不用自定义cmp函数为return a + b < b + a
if (str[0].substr(0, 8) != "00:00:00") cout << "00:00:00 - " << str[0].substr(0, 8) << endl;
for (int i = 0; i < n - 1; i++) {
if (str[i].substr(11) != str[i + 1].substr(0, 8)) cout << str[i].substr(11) << " - " << str[i + 1].substr(0, 8) << endl;
}
if (n >= 1 && str[n - 1].substr(11) != "23:59:59") cout << str[n - 1].substr(11) << " - " << "23:59:59";
return 0;
}