按结束时间排完是什么顺序
六场会按结束时间从早到晚排,把排好后的结束时间用 / 拼起来。
运行下面这段程序:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Seg {
int s, e;
};
int main() {
vector<Seg> iv = {{1, 4}, {2, 3}, {3, 5}, {0, 7}, {5, 6}, {6, 8}};
stable_sort(iv.begin(), iv.end(), [](const Seg& a, const Seg& b) { return a.e < b.e; });
for (size_t i = 0; i < iv.size(); i++) cout << (i ? "/" : "") << iv[i].e;
cout << endl;
}
(本题用 g++ -std=c++17 -O0 编译。)