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>
using namespace std;
const int nx=1e6+5, mod=1e9+7;
long long n, cnt, p[nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
p[0]=1;
for (int i=1; i<nx; i++) p[i]=(p[i-1]*2)%mod;
vector<pair<int, int>> v(n);
for (auto &[x, y]:v) cin>>x>>y;
sort(v.begin(), v.end());
for (int i=0; i<n; i++)
{
int tmp=0;
for (int j=0; j<i; j++) if (v[j].second<v[i].second&&v[j].second>v[i].first) tmp++;
if (tmp>1) return cout<<0, 0;
cnt+=(1-tmp);
}
cout<<p[cnt];
}
/*
4
4 5
3 6
2 7
1 8
4
1 5
2 6
3 7
4 8
4
1 2
3 4
5 7
6 8
*/
# | 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... |