Submission #699439

#TimeUsernameProblemLanguageResultExecution timeMemory
699439aelf2k23초음속철도 (OJUZ11_rail)C++14
0 / 100
3093 ms7756 KiB
#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 = 200005; 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); } 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 n = 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[n] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...