- V<int> dis; // 离散化数组
- V<int> l(n), r(n);
- for (int i = 0; i < n; i++) {
- cin >> l[i] >> r[i];
- dis.push_back(l[i]), dis.push_back(r[i]);
- }
- // 离散化
- sort(all(dis));
- dis.erase(unique(all(dis)), dis.end());
- for (int i = 0; i < n; i++) {
- l[i] = lower_bound(all(dis), l[i]) - dis.begin() + 1;
- r[i] = lower_bound(all(dis), r[i]) - dis.begin() + 1;
- }
- V<int,int> segs;
- for (int i = 0; i < n; i++) segs.push_back({ l[i],r[i] });
- sort(all(segs));