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>
#define int long long
#define ll long long
#define fr first
#define sc second
#define all(s) s.begin(), s.end()
using namespace std;
const int nmax = 400005;
const int mod = 1e9 + 7;
int n, m, dp[nmax];
pair<int,int> a[nmax];
vector<int>vecc;
int32_t main(){
cin >> n >> m;
for(int i=1;i<=m;i++){
cin >> a[i].fr >> a[i].sc;
swap(a[i].fr, a[i].sc);
vecc.push_back(a[i].fr);
vecc.push_back(a[i].sc);
}
vecc.push_back(n);
sort(all(vecc));
vecc.resize(unique(all(vecc)) - vecc.begin());
for(int i=1;i<=m;i++){
a[i].fr = lower_bound(all(vecc), a[i].fr) - vecc.begin();
a[i].sc = lower_bound(all(vecc), a[i].sc) - vecc.begin();
}
sort(a + 1, a + m + 1);
for(int i=1;i<=m;i++){
swap(a[i].fr, a[i].sc);
}
int nn = vecc.size() - 1;
dp[0] = 1;
for(int i=1;i<=m;i++){
for(int j=0;j<a[i].fr;j++){
dp[j] = dp[j] * 2LL % mod;
}
for(int j=a[i].sc;j>=a[i].fr;j--){
dp[a[i].sc] = (dp[a[i].sc] + dp[j]) % mod;
}
}
cout << dp[nn] << '\n';
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |