这是abc410G题的题解代码,想问一下for循环里面的|符号是干嘛的,然后还有<range>库的sort和lower_bound和<algorithm>库中的有什么不同。此外想知道这些是哪个版本的语法
#include <vector>
#include <algorithm>
#include <iostream>
#include <ranges>
int main() {
using namespace std;
unsigned N;
cin >> N;
vector<pair<unsigned, unsigned>> intervals;
intervals.reserve(2 * N);
for (unsigned i{}, a, b; i < N; ++i) {
cin >> a >> b;
if (a > b)
swap(a, b);
intervals.emplace_back(a, b); // Add [a, b]
intervals.emplace_back(b, a + 2 * N); // and [b, a + 2N]
}
// Sort by one endpoint
ranges::sort(intervals, greater{}, &pair<unsigned, unsigned>::second); // 这里
// and find an LIS (Longest Increasing Subsequence)
vector<unsigned> lis_dp;
for (const auto l : intervals | views::keys) // 这里
if (const auto it{ranges::lower_bound(lis_dp, l)}; it != end(lis_dp))
*it = l;
else
lis_dp.emplace_back(l);
// The answer is the length of LIS
cout << size(lis_dp) << endl;
return 0;
}