This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#ifdef __LOCAL__
#include <debug_local.h>
#endif
using namespace std;
const int mod = 1e9 + 7;
void testCase() {
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (auto &[l, r] : a) cin >> l >> r;
sort(a.begin(), a.end());
int ans = 1;
set<int> s;
set<int> c[2];
for (auto [l, r] : a) {
auto it = s.lower_bound(l);
if (it != s.end() && *it < r && *it > l) {
} else {
ans += ans;
if (ans >= mod) ans -= mod;
}
s.insert(r);
it = c[0].lower_bound(l);
bool h = false;
if (it != c[0].end() && *it < r && *it > l) {
h = true;
c[1].insert(r);
}
it = c[1].lower_bound(l);
if (it != c[1].end() && *it < r && *it > l) {
c[0].insert(r);
if (h) {
cout << "0\n";
return;
}
h = true;
}
if (!h) {
c[0].insert(r);
}
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
testCase();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |