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;
#define int long long
#define x first
#define y second
const int mod=1e9+7;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<pair<int,int>> v(n);
for(int i=0;i<n;i++){
cin>>v[i].x>>v[i].y;
}
sort(v.begin(),v.end());
set<int> d;
int ans=1;
for(int i=0;i<n;i++){
while(d.size()&&*d.begin()<v[i].x){
d.erase(d.begin());
}
int cnt=2-d.size();
assert(d.size()<=2);
for(int p:d){
if(p>v[i].y){
cnt++;
}
}
ans=ans*cnt%mod;
//cout<<v[i].x<<' '<<cnt<<endl;
if(ans==0){
cout<<0<<endl;
return 0;
}
d.insert(v[i].y);
}
cout<<ans<<endl;
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... |