結果
問題 |
No.801 エレベーター
|
ユーザー |
|
提出日時 | 2021-10-08 10:14:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 2,062 bytes |
コンパイル時間 | 3,974 ms |
コンパイル使用メモリ | 233,524 KB |
実行使用メモリ | 38,656 KB |
最終ジャッジ日時 | 2024-07-23 03:18:03 |
合計ジャッジ時間 | 6,829 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <atcoder/all> using namespace atcoder; #include <bits/stdc++.h> #define itr(x,c) for(auto x=c.begin();x!=c.end();x++) #define ritr(x,c) for(auto x=c.rbegin();x!=c.rend();x++) #define all(a) (a.begin()),(a.end()) #define rall(a) (a.rbegin()),(a.rend()) using namespace std; using ll=long long; using pll=pair<ll,ll>; template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;} template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;} template<class T>istream& operator >> (istream& is, vector<T>& v) { for(T& x:v) is >> x; return is; } template<class T>ostream& operator << (ostream& os, const vector<T>& v) {for(int i=0;i<v.size();i++) {os << v[i] << (i+1 == v.size() ? "":" ");} return os;} template<class... A> void pt() { std::cout << "\n"; } template<class... A> void pt_rest() { std::cout << "\n"; } template<class T, class... A> void pt_rest(const T& first, const A&... rest) { std::cout << " " << first; pt_rest(rest...); } template<class T, class... A> void pt(const T& first, const A&... rest) { std::cout << first; pt_rest(rest...); } template<class T1, class T2>istream& operator >> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; } static const ll INF=1e18+7; static const ll MAX=101010; static const ll MOD=1e9+7; static const double PI=acos(-1); static const double EPS=1e-10; //static const ll MOD=998244353; using v1d=vector<modint1000000007>; using v2d=vector<v1d>; using v3d=vector<v2d>; using v4d=vector<v3d>; int main(void) { cin.tie(nullptr); ios::sync_with_stdio(false); ll i,j,k; ll N,M,K;cin>>N>>M>>K; vector<ll> l(M),r(M); for(i=0;i<M;i++)cin>>l[i]>>r[i]; v2d dp(K+1,v1d(N+1,0)); dp[0][1]=1; for(k=0;k<K;k++){ v1d s(N+1,0); for(i=1;i<=N;i++)s[i]=s[i-1]+dp[k][i]; v1d c(N+2,0); for(i=0;i<M;i++){ modint1000000007 t=s[r[i]]-s[l[i]-1]; c[l[i]]+=t; c[r[i]+1]-=t; } for(i=1;i<=N;i++)c[i]+=c[i-1]; for(i=1;i<=N;i++)dp[k+1][i]=c[i]; } pt(dp[K][N].val()); }