結果
問題 | No.801 エレベーター |
ユーザー |
![]() |
提出日時 | 2019-03-18 16:31:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 1,903 bytes |
コンパイル時間 | 1,119 ms |
コンパイル使用メモリ | 123,316 KB |
最終ジャッジ日時 | 2025-01-06 23:29:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) //#define cerr if(false) cerr #define show(...) cerr << #__VA_ARGS__ << " = ",debug(__VA_ARGS__); using namespace std; using ll = long long; using pii = pair<int,int>; template<typename T, typename S> ostream &operator<<(ostream &os, pair<T, S> a){ os << '(' << a.first << ',' << a.second << ')'; return os; } template<typename T> ostream &operator<<(ostream &os, vector<T> v){ for(auto x:v)os << x << ' '; return os; } void debug(){cerr << '\n';} template<typename H, typename... T> void debug(H a, T... b){ cerr << a; if(sizeof...(b))cerr << ", "; debug(b...); } int mod = 1e9+7; inline int add(int a,int b){ a += b; if(a >= mod)a-=mod; return a; } inline int sub(int a,int b){ a-=b; if(a<0)a+=mod; return a; } inline int mul(int a,int b){ return (ll)a * b % mod; } int dp[3005][3005]; int main(){ int n,m,k; cin >> n >> m >> k; vector<int>L(m),R(m); rep(i,m){ cin >> L[i] >> R[i]; } dp[0][1] = 1; for(int i = 0; i < k; i++){ for(int j = 0; j < n; j++){ dp[i][j+1] = add(dp[i][j+1], dp[i][j]); } for(int j = 0; j < m; j++){ int sum = sub(dp[i][R[j]],dp[i][L[j]-1]); dp[i+1][L[j]] = add(dp[i+1][L[j]], sum); dp[i+1][R[j]+1] = sub(dp[i+1][R[j]+1],sum); } for(int j = 0; j < n; j++){ dp[i+1][j+1] = add(dp[i+1][j+1], dp[i+1][j]); } } cout << dp[k][n] << endl; }